diff options
-rw-r--r-- | service/pixelated/adapter/pixelated_mail_sender.py | 4 | ||||
-rw-r--r-- | service/test/adapter/pixelated_mail_sender_test.py | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/service/pixelated/adapter/pixelated_mail_sender.py b/service/pixelated/adapter/pixelated_mail_sender.py index 6f6340da..486816ac 100644 --- a/service/pixelated/adapter/pixelated_mail_sender.py +++ b/service/pixelated/adapter/pixelated_mail_sender.py @@ -18,9 +18,9 @@ from pixelated.support.functional import flatten class PixelatedMailSender(): - def __init__(self, account_email_address): + def __init__(self, account_email_address, smtp_client=None): self.account_email_address = account_email_address - self.smtp_client = smtplib.SMTP('localhost', 4650) + self.smtp_client = smtp_client or smtplib.SMTP('localhost', 4650) def sendmail(self, mail): recipients = flatten([mail.get_to(), mail.get_cc(), mail.get_bcc()]) diff --git a/service/test/adapter/pixelated_mail_sender_test.py b/service/test/adapter/pixelated_mail_sender_test.py index 0a8c017b..aadeaeab 100644 --- a/service/test/adapter/pixelated_mail_sender_test.py +++ b/service/test/adapter/pixelated_mail_sender_test.py @@ -23,8 +23,8 @@ import test_helper class PixelatedMailSenderTest(unittest.TestCase): def setUp(self): self.mail_address = "pixelated@pixelated.org" - self.mail_sender = PixelatedMailSender(self.mail_address) - self.mail_sender.smtp_client = mock() + self.smtp_client = mock() + self.mail_sender = PixelatedMailSender(self.mail_address, self.smtp_client) def test_send_mail_sends_to_To_Cc_and_Bcc(self): mail_dict = test_helper.mail_dict() @@ -41,4 +41,4 @@ class PixelatedMailSenderTest(unittest.TestCase): 'anothercc@pixelated.org', 'bcc@pixelated.org', 'anotherbcc@pixelated.org'] - verify(self.mail_sender.smtp_client).sendmail(self.mail_address, expected_recipients, "mail as smtp string") + verify(self.smtp_client).sendmail(self.mail_address, expected_recipients, "mail as smtp string") |