Skip to content

Commit

Permalink
tests/notifications: fix flaky email test
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Dec 21, 2023
1 parent 06b9401 commit f450f81
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog/_4567.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@

- test helper for testing emails
- initial doc on testing

### Fixed

- fixed the flaky test_notify_creator_exclude_moderator test
8 changes: 5 additions & 3 deletions tests/notifications/test_creator_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.urls import reverse

from adhocracy4.test.helpers import redirect_target
from tests.helpers import get_emails_for_address


@pytest.mark.django_db
Expand Down Expand Up @@ -33,10 +34,11 @@ def test_notify_creator_exclude_moderator(idea, comment_factory, user):
comment_factory(content_object=idea)

assert len(mail.outbox) == 3
mails = get_emails_for_address(creator_moderator.email)
assert len(mails) == 1
# moderator notification instead of creator notification
assert mail.outbox[1].to[0] == creator_moderator.email
assert not mail.outbox[1].subject.startswith("Reaction to your contribution")
assert mail.outbox[1].subject.startswith("A comment was added to the project")
assert not mails[0].subject.startswith("Reaction to your contribution")
assert mails[0].subject.startswith("A comment was added to the project")


@pytest.mark.django_db
Expand Down

0 comments on commit f450f81

Please sign in to comment.