diff options
author | Victor Shyba <victor.shyba@gmail.com> | 2015-06-07 06:33:29 -0300 |
---|---|---|
committer | Victor Shyba <victor.shyba@gmail.com> | 2015-06-07 06:33:29 -0300 |
commit | 4981e7ad505cd1cea767e7d12fcf9c6521994f86 (patch) | |
tree | 3c2c0e2289e2f714e7aef3b8b865b87daa453b81 /service/test | |
parent | a6d2be2e827097fcd89d7759d677e420723cb607 (diff) |
fixes tests for smtp gateway
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/unit/adapter/services/test_mail_sender.py | 16 | ||||
-rw-r--r-- | service/test/unit/bitmask_libraries/test_smtp.py | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/service/test/unit/adapter/services/test_mail_sender.py b/service/test/unit/adapter/services/test_mail_sender.py index 0e7ec015..421a5f6d 100644 --- a/service/test/unit/adapter/services/test_mail_sender.py +++ b/service/test/unit/adapter/services/test_mail_sender.py @@ -17,7 +17,7 @@ from twisted.trial import unittest from mockito import mock, when, verify, any, unstub from pixelated.adapter.services.mail_sender import MailSender, SMTPDownException -from pixelated.adapter.model.mail import PixelatedMail, InputMail +from pixelated.adapter.model.mail import InputMail from test.support.test_helper import mail_dict from twisted.internet import reactor from twisted.internet.defer import Deferred @@ -25,13 +25,14 @@ from twisted.internet.defer import Deferred class MailSenderTest(unittest.TestCase): def setUp(self): - self.ensure_smtp_is_running_cb = lambda: True - self.ensure_smtp_is_not_running_cb = lambda: False + self.smtp = mock() + self.smtp.local_smtp_port_number = 4650 + self.smtp.ensure_running = lambda: True def test_sendmail(self): when(reactor).connectTCP('localhost', 4650, any()).thenReturn(None) input_mail = InputMail.from_dict(mail_dict()) - mail_sender = MailSender('someone@somedomain.tld', self.ensure_smtp_is_running_cb) + mail_sender = MailSender('someone@somedomain.tld', self.smtp) return self._succeed(mail_sender.sendmail(input_mail)) @@ -43,7 +44,7 @@ class MailSenderTest(unittest.TestCase): input_mail = InputMail.from_dict(mail_dict()) - mail_sender = MailSender('someone@somedomain.tld', self.ensure_smtp_is_running_cb) + mail_sender = MailSender('someone@somedomain.tld', self.smtp) sent_deferred = mail_sender.sendmail(input_mail) @@ -54,7 +55,7 @@ class MailSenderTest(unittest.TestCase): def test_senmail_returns_deffered(self): when(reactor).connectTCP('localhost', 4650, any()).thenReturn(None) input_mail = InputMail.from_dict(mail_dict()) - mail_sender = MailSender('someone@somedomain.tld', self.ensure_smtp_is_running_cb) + mail_sender = MailSender('someone@somedomain.tld', self.smtp) deferred = mail_sender.sendmail(input_mail) @@ -64,7 +65,8 @@ class MailSenderTest(unittest.TestCase): return self._succeed(deferred) def test_doesnt_send_mail_if_smtp_is_not_running(self): - mail_sender = MailSender('someone@somedomain.tld', self.ensure_smtp_is_not_running_cb) + self.smtp.ensure_running = lambda: False + mail_sender = MailSender('someone@somedomain.tld', self.smtp) deferred = mail_sender.sendmail({}) diff --git a/service/test/unit/bitmask_libraries/test_smtp.py b/service/test/unit/bitmask_libraries/test_smtp.py index aa2bc9ba..5987415c 100644 --- a/service/test/unit/bitmask_libraries/test_smtp.py +++ b/service/test/unit/bitmask_libraries/test_smtp.py @@ -69,7 +69,7 @@ class LeapSmtpTest(AbstractLeapTest): smtp = LeapSmtp(self.provider, self.auth.username, self.auth.session_id, self.keymanager) port = 500 - smtp.TWISTED_PORT = port + smtp.local_smtp_port_number = port gateway_mock.return_value = (None, None) with HTTMock(ca_cert_mock, not_found_mock): smtp.ensure_running() |