Skip to content

Commit

Permalink
chore: added unit test for archive_or_delete_opted_in_operation_detail
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-williams committed Jan 14, 2025
1 parent 12b2b85 commit 73d0881
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,26 @@ def test_update_opted_in_operation_detail():
assert users_operation.opted_in_operation.meets_notification_to_director_on_criteria_change is False
assert users_operation.opted_in_operation.updated_by == approved_user_operator.user
assert users_operation.opted_in_operation.updated_at is not None

@staticmethod
def test_archive_or_delete_opted_in_operation_detail():
approved_user_operator = baker.make_recipe('utils.approved_user_operator')
users_operation = baker.make_recipe(
'utils.operation',
registration_purpose=Operation.Purposes.OPTED_IN_OPERATION,
created_by=approved_user_operator.user,
opted_in_operation=baker.make_recipe(
'utils.opted_in_operation_detail', created_by=approved_user_operator.user
),
operator=approved_user_operator.operator,
opt_in=True,
)
assert OptedInOperationDetail.objects.count() == 1
OptedInOperationDataAccessService.archive_or_delete_opted_in_operation_detail(
approved_user_operator.user.user_guid, users_operation.id
)
users_operation.refresh_from_db()
# at the moment there's no easy way to tell whether a record has been deleted or archived, so not testing any further than
# this for now. We may eventually need to implement a way to fetch archived records from the db.
assert users_operation.opted_in_operation is None
assert OptedInOperationDetail.objects.count() == 0

0 comments on commit 73d0881

Please sign in to comment.