From 0ac91fa8d1e70e7d9a807472582120396b3953a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vergez?= Date: Wed, 28 Feb 2024 23:16:57 +0100 Subject: [PATCH] =?UTF-8?q?fix=20:=20mauvais=20e-mail=20envoy=C3=A9=20sur?= =?UTF-8?q?=20la=20derni=C3=A8re=20notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dora/notifications/tasks/tests/tests_users.py | 13 +++++++++++++ dora/notifications/tasks/users.py | 4 +++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dora/notifications/tasks/tests/tests_users.py b/dora/notifications/tasks/tests/tests_users.py index 19b26704..3ca82813 100644 --- a/dora/notifications/tasks/tests/tests_users.py +++ b/dora/notifications/tasks/tests/tests_users.py @@ -78,6 +78,19 @@ def test_user_without_structure_task_should_trigger(user_without_structure_task) assert len(mail.outbox) == cnt assert mail.outbox[cnt - 1].to == [user.email] + # le contenu de l'e-mail est différent pour la dernière notification + match cnt: + case 4: + assert ( + mail.outbox[cnt - 1].subject + == "Dernier rappel avant suppression" + ) + case _: + assert ( + mail.outbox[cnt - 1].subject + == "Rappel : Identifiez votre structure sur DORA" + ) + with freeze_time(now + relativedelta(days=day + 1)): ok, _, _ = user_without_structure_task.run() assert not ok diff --git a/dora/notifications/tasks/users.py b/dora/notifications/tasks/users.py index 662a8c36..33af8cab 100644 --- a/dora/notifications/tasks/users.py +++ b/dora/notifications/tasks/users.py @@ -52,7 +52,9 @@ def process(cls, notification: Notification): match notification.counter: case 0 | 1 | 2 | 3: try: - send_user_without_structure_notification(notification.owner_user) + send_user_without_structure_notification( + notification.owner_user, deletion=notification.counter == 3 + ) except Exception as ex: raise TaskError( f"Erreur d'envoi du mail pour un utilisateur sans structure ({notification}) : {ex}"