|
21 | 21 | ListStatus,
|
22 | 22 | )
|
23 | 23 | from ..tasks import (
|
| 24 | + complete_and_notify, |
24 | 25 | delete_destruction_list,
|
25 | 26 | delete_destruction_list_item,
|
26 | 27 | process_review_response,
|
@@ -335,3 +336,35 @@ def test_processing_list_with_failed_item(self):
|
335 | 336 | item.internal_results,
|
336 | 337 | {"deleted_resources": {}, "resources_to_delete": {}, "traceback": ""},
|
337 | 338 | )
|
| 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 | + self.assertEqual(mail.outbox[0].subject, "DELETED!") |
| 366 | + |
| 367 | + list.refresh_from_db() |
| 368 | + |
| 369 | + self.assertEqual(list.status, ListStatus.deleted) |
| 370 | + self.assertEqual(list.processing_status, InternalStatus.succeeded) |
0 commit comments