-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send_queued() now raises an exception if batch_delivery_timeout is ex…
…ceeded.
- Loading branch information
Showing
3 changed files
with
36 additions
and
19 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 |
---|---|---|
|
@@ -40,7 +40,7 @@ class SlowTestBackend(mail.backends.base.BaseEmailBackend): | |
''' | ||
|
||
def send_messages(self, email_messages): | ||
time.sleep(10) | ||
time.sleep(5) | ||
|
||
|
||
class MailTest(TestCase): | ||
|
@@ -496,8 +496,14 @@ def test_batch_delivery_timeout(self): | |
email = Email.objects.create(to=['[email protected]'], | ||
from_email='[email protected]', subject='', | ||
message='', status=STATUS.queued, backend_alias='slow_backend') | ||
send_queued() | ||
|
||
start_time = timezone.now() | ||
# slow backend sleeps for 5 seconds, so we should get a timeout error since we set | ||
# BATCH_DELIVERY_TIMEOUT timeout to 2 seconds in test_settings.py | ||
with self.assertRaises(TimeoutError): | ||
send_queued() | ||
end_time = timezone.now() | ||
# Assert that running time is less than 3 seconds (2 seconds timeout + 1 second buffer) | ||
self.assertTrue(end_time - start_time < timezone.timedelta(seconds=3)) | ||
|
||
@patch('post_office.signals.email_queued.send') | ||
def test_backend_signal(self, mock): | ||
|