Skip to content

Commit 0dcc21b

Browse files
committed
✅ [#85] Test notification on successful deletion
1 parent b63aaab commit 0dcc21b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

backend/src/openarchiefbeheer/accounts/tests/factories.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class UserFactory(DjangoModelFactory):
2121
last_name = factory.Faker("last_name")
2222
password = factory.PostGenerationMethodCall("set_password", "password")
2323
role = factory.SubFactory(RoleFactory)
24+
email = factory.Faker("email")
2425

2526
class Meta:
2627
model = User

backend/src/openarchiefbeheer/destruction/tests/test_tasks.py

+32
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
ListStatus,
2222
)
2323
from ..tasks import (
24+
complete_and_notify,
2425
delete_destruction_list,
2526
delete_destruction_list_item,
2627
process_review_response,
@@ -335,3 +336,34 @@ def test_processing_list_with_failed_item(self):
335336
item.internal_results,
336337
{"deleted_resources": {}, "resources_to_delete": {}, "traceback": ""},
337338
)
339+
340+
def test_complete_and_notify(self):
341+
list = DestructionListFactory.create(
342+
processing_status=InternalStatus.processing,
343+
status=ListStatus.ready_to_delete,
344+
)
345+
assignees = DestructionListAssigneeFactory.create_batch(
346+
3, destruction_list=list
347+
)
348+
349+
with (
350+
patch(
351+
"openarchiefbeheer.destruction.utils.EmailConfig.get_solo",
352+
return_value=EmailConfig(
353+
subject_successful_deletion="DELETED!",
354+
body_successful_deletion="Wohoo deleted list",
355+
),
356+
),
357+
):
358+
complete_and_notify(list.pk)
359+
360+
self.assertEqual(len(mail.outbox), 1)
361+
self.assertEqual(
362+
sorted(mail.outbox[0].to),
363+
sorted([assignee.user.email for assignee in assignees]),
364+
)
365+
366+
list.refresh_from_db()
367+
368+
self.assertEqual(list.status, ListStatus.deleted)
369+
self.assertEqual(list.processing_status, InternalStatus.succeeded)

0 commit comments

Comments
 (0)