-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from eduardocardoso/96-custom-sender
Customize sender for email check
- Loading branch information
Showing
4 changed files
with
27 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -233,6 +233,7 @@ once per minute, this would cost you ~$5.60/month. | |
|
||
**Custom Settings** | ||
|
||
* ``WATCHMAN_EMAIL_SENDER`` (default: ``[email protected]``): Specify an email to be the sender of the test email | ||
* ``WATCHMAN_EMAIL_RECIPIENTS`` (default: ``[[email protected]]``): Specify a list of email addresses to send the test email | ||
* ``WATCHMAN_EMAIL_HEADERS`` (default: ``{}``): Specify a dict of custom headers to be added to the test email | ||
|
||
|
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 |
---|---|---|
|
@@ -413,3 +413,27 @@ def test_email_check_with_custom_headers(self): | |
'foo': 'bar', | ||
} | ||
self.assertEqual(sent_email.extra_headers, expected_headers) | ||
|
||
def def_test_email_with_default_sender(self): | ||
checks._check_email() | ||
|
||
# Test that one message has been sent. | ||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
sent_email = mail.outbox[0] | ||
expected_sender = '[email protected]' | ||
self.assertEqual(sent_email.from_email, expected_sender) | ||
|
||
@override_settings(WATCHMAN_EMAIL_SENDER='[email protected]') | ||
def def_test_email_with_custom_sender(self): | ||
# Have to manually reload settings here because override_settings | ||
# happens after self.setUp() | ||
reload_settings() | ||
checks._check_email() | ||
|
||
# Test that one message has been sent. | ||
self.assertEqual(len(mail.outbox), 1) | ||
|
||
sent_email = mail.outbox[0] | ||
expected_sender = '[email protected]' | ||
self.assertEqual(sent_email.from_email, expected_sender) |
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 |
---|---|---|
|
@@ -48,7 +48,7 @@ def _check_email(): | |
email = EmailMessage( | ||
"django-watchman email check", | ||
"This is an automated test of the email system.", | ||
"[email protected]", | ||
watchman_settings.WATCHMAN_EMAIL_SENDER, | ||
watchman_settings.WATCHMAN_EMAIL_RECIPIENTS, | ||
headers=headers, | ||
) | ||
|
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
WATCHMAN_TOKENS = getattr(settings, 'WATCHMAN_TOKENS', None) | ||
WATCHMAN_TOKEN_NAME = getattr(settings, 'WATCHMAN_TOKEN_NAME', 'watchman-token') | ||
WATCHMAN_ERROR_CODE = getattr(settings, 'WATCHMAN_ERROR_CODE', 500) | ||
WATCHMAN_EMAIL_SENDER = getattr(settings, 'WATCHMAN_EMAIL_SENDER', '[email protected]') | ||
WATCHMAN_EMAIL_RECIPIENTS = getattr(settings, 'WATCHMAN_EMAIL_RECIPIENTS', ['[email protected]']) | ||
WATCHMAN_EMAIL_HEADERS = getattr(settings, 'WATCHMAN_EMAIL_HEADERS', {}) | ||
|
||
|