diff --git a/bc_obps/service/tests/data_access_service/test_data_access_opted_in_operation_detail_service.py b/bc_obps/service/tests/data_access_service/test_data_access_opted_in_operation_detail_service.py index 51023ae516..138eddb716 100644 --- a/bc_obps/service/tests/data_access_service/test_data_access_opted_in_operation_detail_service.py +++ b/bc_obps/service/tests/data_access_service/test_data_access_opted_in_operation_detail_service.py @@ -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