-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure to always send email_queued signal when creating emails with priority != now
- Loading branch information
1 parent
12a68e5
commit 3a5801b
Showing
4 changed files
with
33 additions
and
3 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
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import os | ||
from email.mime.image import MIMEImage | ||
from unittest import mock | ||
|
||
from django.conf import settings | ||
from django.core.files.images import File | ||
from django.core.mail import EmailMultiAlternatives, send_mail, EmailMessage | ||
|
@@ -164,3 +166,18 @@ def test_default_priority_now(self): | |
email = Email.objects.latest('id') | ||
self.assertEqual(email.status, STATUS.sent) | ||
self.assertEqual(num_sent, 1) | ||
|
||
@override_settings( | ||
EMAIL_BACKEND='post_office.EmailBackend', | ||
POST_OFFICE={ | ||
'DEFAULT_PRIORITY': 'medium', | ||
'BACKENDS': {'default': 'django.core.mail.backends.dummy.EmailBackend'} | ||
} | ||
) | ||
@mock.patch('post_office.signals.email_queued.send') | ||
def test_email_queued_signal(self, mock): | ||
# If DEFAULT_PRIORITY is not "now", the email_queued signal should be sent | ||
send_mail('Test', 'Message', '[email protected]', ['[email protected]']) | ||
email = Email.objects.latest('id') | ||
self.assertEqual(email.status, STATUS.queued) | ||
self.assertEqual(mock.call_count, 1) |
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