Skip to content

Commit

Permalink
chore: updated unit test for data_access_opted_in_operation_detail_se…
Browse files Browse the repository at this point in the history
…rvice
  • Loading branch information
andrea-williams committed Jan 16, 2025
1 parent cb806ec commit f0053e1
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,21 @@ def test_archive_or_delete_opted_in_operation_detail():
opt_in=True,
)
assert OptedInOperationDetail.objects.count() == 1

opted_in_detail = users_operation.opted_in_operation

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

if users_operation.status == Operation.Statuses.REGISTERED:
opted_in_detail.refresh_from_db()
assert opted_in_detail.archived_at is not None
assert opted_in_detail.archived_by is not None
else:
with pytest.raises(OptedInOperationDetail.DoesNotExist):
opted_in_detail.refresh_from_db() # this should raise an exception because it's been deleted

0 comments on commit f0053e1

Please sign in to comment.