Skip to content

Commit

Permalink
fix existing tests that created blank ReviewActionReasons
Browse files Browse the repository at this point in the history
  • Loading branch information
eviljeff committed Jul 30, 2024
1 parent 4659f7c commit 2161188
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
18 changes: 13 additions & 5 deletions src/olympia/abuse/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,14 @@ def test_list(self):
zab = CinderPolicy.objects.create(name='Zab', parent=foo, uuid=uuid.uuid4())
lorem = CinderPolicy.objects.create(name='Lorem', uuid=uuid.uuid4())
CinderPolicy.objects.create(name='Ipsum', uuid=uuid.uuid4())
ReviewActionReason.objects.create(name='Attached to Zab', cinder_policy=zab)
ReviewActionReason.objects.create(name='Attached to Lorem', cinder_policy=lorem)
ReviewActionReason.objects.create(
name='Also attached to Lorem', cinder_policy=lorem
name='Attached to Zab', cinder_policy=zab, canned_response='.'
)
ReviewActionReason.objects.create(
name='Attached to Lorem', cinder_policy=lorem, canned_response='.'
)
ReviewActionReason.objects.create(
name='Also attached to Lorem', cinder_policy=lorem, canned_response='.'
)

with self.assertNumQueries(7):
Expand Down Expand Up @@ -636,8 +640,12 @@ def test_list_order_by_reviewreason(self):
zab = CinderPolicy.objects.create(name='Zab', parent=foo, uuid=uuid.uuid4())
lorem = CinderPolicy.objects.create(name='Lorem', uuid=uuid.uuid4())
CinderPolicy.objects.create(name='Ipsum', uuid=uuid.uuid4())
ReviewActionReason.objects.create(name='Attached to Zab', cinder_policy=zab)
ReviewActionReason.objects.create(name='Attached to Lorem', cinder_policy=lorem)
ReviewActionReason.objects.create(
name='Attached to Zab', cinder_policy=zab, canned_response='.'
)
ReviewActionReason.objects.create(
name='Attached to Lorem', cinder_policy=lorem, canned_response='.'
)

with self.assertNumQueries(7):
# - 2 savepoints (tests)
Expand Down
4 changes: 3 additions & 1 deletion src/olympia/abuse/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,9 @@ def test_old_unused_policies_deleted(self):
)
old_policy_with_reason.update(modified=days_ago(1))
ReviewActionReason.objects.create(
name='a review reason', cinder_policy=old_policy_with_reason
name='a review reason',
cinder_policy=old_policy_with_reason,
canned_response='.',
)
CinderPolicy.objects.create(
uuid=self.policy['uuid'],
Expand Down
6 changes: 2 additions & 4 deletions src/olympia/activity/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,10 @@ def test_can_not_see_module_in_admin_without_permissions(self):

def test_select_labels_inactive_reasons(self):
reason_1 = ReviewActionReason.objects.create(
name='reason 1',
is_active=True,
name='reason 1', is_active=True, canned_response='.'
)
inactive_reason = ReviewActionReason.objects.create(
name='inactive reason',
is_active=False,
name='inactive reason', is_active=False, canned_response='.'
)
user = user_factory(email='[email protected]')
self.grant_permission(user, '*:*')
Expand Down
6 changes: 2 additions & 4 deletions src/olympia/activity/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,10 @@ def test_review_action_reason_log(self):
# Creating an activity log with one or more`reason` arguments does
# create ReviewActionReasonLogs.
reason_1 = ReviewActionReason.objects.create(
name='a reason',
is_active=True,
name='a reason', is_active=True, canned_response='.'
)
reason_2 = ReviewActionReason.objects.create(
name='reason 2',
is_active=True,
name='reason 2', is_active=True, canned_response='.'
)
ActivityLog.objects.create(
action,
Expand Down
10 changes: 7 additions & 3 deletions src/olympia/reviewers/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,14 @@ def test_list(self):
zab = CinderPolicy.objects.create(name='Zab', parent=foo, uuid=uuid.uuid4())
lorem = CinderPolicy.objects.create(name='Lorem', uuid=uuid.uuid4())
CinderPolicy.objects.create(name='Ipsum', uuid=uuid.uuid4())
ReviewActionReason.objects.create(name='Attached to Zab', cinder_policy=zab)
ReviewActionReason.objects.create(name='Attached to Lorem', cinder_policy=lorem)
ReviewActionReason.objects.create(
name='Also attached to Lorem', cinder_policy=lorem
name='Attached to Zab', cinder_policy=zab, canned_response='.'
)
ReviewActionReason.objects.create(
name='Attached to Lorem', cinder_policy=lorem, canned_response='.'
)
ReviewActionReason.objects.create(
name='Also attached to Lorem', cinder_policy=lorem, canned_response='.'
)

with self.assertNumQueries(6):
Expand Down
6 changes: 3 additions & 3 deletions src/olympia/reviewers/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ def test_reject_versions_with_resolved_cinder_job(self):
)
policies = [CinderPolicy.objects.create(name='policy', uuid='12345678')]
review_action_reason = ReviewActionReason.objects.create(
cinder_policy=policies[0]
cinder_policy=policies[0], canned_response='.'
)
cinder_job.pending_rejections.add(self.version.reviewerflags)
log = ActivityLog.objects.create(
Expand Down Expand Up @@ -1432,7 +1432,7 @@ def test_reject_versions_with_resolved_cinder_job_no_third_party(self):
)
policies = [CinderPolicy.objects.create(name='policy', uuid='12345678')]
review_action_reason = ReviewActionReason.objects.create(
cinder_policy=policies[0]
cinder_policy=policies[0], canned_response='.'
)
cinder_job.pending_rejections.add(self.version.reviewerflags)
log = ActivityLog.objects.create(
Expand Down Expand Up @@ -1477,7 +1477,7 @@ def test_reject_versions_with_multiple_delayed_rejections(self):
)
policies = [CinderPolicy.objects.create(name='policy', uuid='12345678')]
review_action_reason = ReviewActionReason.objects.create(
cinder_policy=policies[0]
cinder_policy=policies[0], canned_response='.'
)
cinder_job.pending_rejections.add(self.version.reviewerflags)
# Create 2 ActivityLogs on different dates delay-rejecting that add-on,
Expand Down
2 changes: 1 addition & 1 deletion src/olympia/reviewers/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_reasons(self):
self.empty_reason = ReviewActionReason.objects.create(
name='d reason',
is_active=True,
canned_response='',
canned_block_reason='',
)
form = self.get_form()
choices = form.fields['reasons'].choices
Expand Down
8 changes: 4 additions & 4 deletions src/olympia/reviewers/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,13 @@ def test_log_action_sets_policies_and_reasons_with_allow_reasons(self):
data = {
'reasons': [
ReviewActionReason.objects.create(
name='reason 1',
is_active=True,
name='reason 1', is_active=True, canned_response='.'
),
ReviewActionReason.objects.create(
name='reason 2',
is_active=True,
cinder_policy=CinderPolicy.objects.create(uuid='y'),
canned_response='.',
),
],
# ignored - the action doesn't allow_policies
Expand Down Expand Up @@ -1052,13 +1052,13 @@ def test_log_action_sets_policies_with_allow_policies(self):
# ignored - the action doesn't allow_reasons
'reasons': [
ReviewActionReason.objects.create(
name='reason 1',
is_active=True,
name='reason 1', is_active=True, canned_response='.'
),
ReviewActionReason.objects.create(
name='reason 2',
is_active=True,
cinder_policy=CinderPolicy.objects.create(uuid='y'),
canned_response='.',
),
],
'cinder_policies': [
Expand Down

0 comments on commit 2161188

Please sign in to comment.