|
|
@ -1,4 +1,4 @@ |
|
|
|
from smtplib import SMTPServerDisconnected |
|
|
|
from smtplib import SMTPServerDisconnected, SMTPDataError |
|
|
|
from unittest.mock import Mock, patch |
|
|
|
|
|
|
|
from django.test import TestCase |
|
|
@ -25,3 +25,12 @@ class EmailsTestCase(TestCase): |
|
|
|
t.run() |
|
|
|
|
|
|
|
self.assertEqual(mock_msg.send.call_count, 3) |
|
|
|
|
|
|
|
def test_it_retries_smtp_data_error(self, mock_time): |
|
|
|
mock_msg = Mock() |
|
|
|
mock_msg.send = Mock(side_effect=[SMTPDataError(454, "hello"), None]) |
|
|
|
|
|
|
|
t = EmailThread(mock_msg) |
|
|
|
t.run() |
|
|
|
|
|
|
|
self.assertEqual(mock_msg.send.call_count, 2) |