Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
fix : mauvais e-mail envoyé sur la dernière notification
Browse files Browse the repository at this point in the history
  • Loading branch information
ikarius committed Feb 28, 2024
1 parent 40e548e commit 0ac91fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions dora/notifications/tasks/tests/tests_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion dora/notifications/tasks/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit 0ac91fa

Please sign in to comment.