Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/olympia/abuse/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def create_and_execute_decision(
'private_notes': decision_notes[
: ContentDecision._meta.get_field('reasoning').max_length
],
'override_of': None,
'override_of': job.final_decision if job else None,
'cinder_job': job,
'from_job_queue': job_queue,
},
Expand Down
39 changes: 39 additions & 0 deletions src/olympia/abuse/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,45 @@ def test_create_and_execute_decision_no_job(self):
assert notify_mock.call_count == 1
assert list(decision.policies.all()) == [policy_a, policy_b]

def test_create_and_execute_decision_override_decision(self):
target = user_factory()
cinder_job = CinderJob.objects.create(job_id='1234')
earlier_decision = ContentDecision.objects.create(
cinder_id='1234',
action=DECISION_ACTIONS.AMO_APPROVE,
cinder_job=cinder_job,
user=target,
)
AbuseReport.objects.create(user=target, cinder_job=cinder_job)
policy_a = CinderPolicy.objects.create(uuid='123-45', name='aaa', text='AAA')
policy_b = CinderPolicy.objects.create(uuid='678-90', name='bbb', text='BBB')

with (
mock.patch.object(ContentActionBanUser, 'process_action') as action_mock,
mock.patch.object(ContentActionBanUser, 'notify_owners') as notify_mock,
):
action_mock.return_value = None
CinderJob.create_and_execute_decision(
cinder_job,
target=target,
decision_cinder_id='12345',
decision_action=DECISION_ACTIONS.AMO_BAN_USER.value,
decision_notes='teh notes',
policy_ids=['123-45', '678-90'],
job_queue='some-cinder-queue',
)
assert cinder_job.decision == earlier_decision
assert cinder_job.final_decision.cinder_id == '12345'
assert cinder_job.final_decision.action == DECISION_ACTIONS.AMO_BAN_USER
assert cinder_job.final_decision.private_notes == 'teh notes'
assert cinder_job.final_decision.reasoning == ''
assert cinder_job.final_decision.from_job_queue == 'some-cinder-queue'
assert cinder_job.final_decision.user == target
assert cinder_job.final_decision.override_of == earlier_decision
assert action_mock.call_count == 1
assert notify_mock.call_count == 1
assert list(cinder_job.final_decision.policies.all()) == [policy_a, policy_b]

@override_switch('dsa-cinder-forwarded-review', active=True)
def test_process_queue_move_into_reviewer_handled(self):
addon = addon_factory(file_kw={'is_signed': True})
Expand Down