-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add helper and some initial docs about testing
- Loading branch information
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### Added | ||
|
||
- test helper for testing emails | ||
- initial doc on testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
Emails are not guaranteed to be sent in a deterministic order, 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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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""" | ||
mails = list(filter(lambda mails: mails.to[0] == email_address, mail.outbox)) | ||
return mails |