Skip to content

Commit

Permalink
tests: add helper and some initial docs about testing
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Dec 21, 2023
1 parent ef2f034 commit 7f7cead
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Tests

## Backend Tests

We use pytest in combination with pytest-django and factoryboy to write backend
tests.

### Notes

#### Testing Emails

The django email backend does not guarantee a deterministic order of the mails,
so checking against an index will result in flaky tests. If you want to assert
that a mail was sent use one of the helper functions in `tests/helpers.py`.
7 changes: 7 additions & 0 deletions tests/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.core import mail


def get_emails_for_address(email_address):
"""Return all mails send to email_address"""
index = list(filter(lambda mails: mails.to[0] == email_address, mail.outbox))
return index

0 comments on commit 7f7cead

Please sign in to comment.