summaryrefslogtreecommitdiff
path: root/service/test/unit
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-11-03 17:12:15 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-11-03 17:13:56 +0100
commitaf7631369c96d3da54abb4e1cab44ea61151c481 (patch)
treed08187e30b2d49df722eaf97c6cf5a5c0540d831 /service/test/unit
parent5c3468304f13fa0fe279a6e04fb90432d6737345 (diff)
Add new MailSender based on OutgoingMail
- Issue #499 - No longer needs local smtp port
Diffstat (limited to 'service/test/unit')
-rw-r--r--service/test/unit/adapter/services/test_mail_sender.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/service/test/unit/adapter/services/test_mail_sender.py b/service/test/unit/adapter/services/test_mail_sender.py
index 7806c92a..ca68bdc6 100644
--- a/service/test/unit/adapter/services/test_mail_sender.py
+++ b/service/test/unit/adapter/services/test_mail_sender.py
@@ -13,16 +13,41 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+from leap.mail.outgoing.service import OutgoingMail
from twisted.trial import unittest
from mockito import mock, when, verify, any, unstub
-from pixelated.adapter.services.mail_sender import LocalSmtpMailSender, SMTPDownException
+from pixelated.adapter.services.mail_sender import LocalSmtpMailSender, SMTPDownException, MailSender
from pixelated.adapter.model.mail import InputMail
+from pixelated.support.functional import flatten
from test.support.test_helper import mail_dict
-from twisted.internet import reactor
+from twisted.internet import reactor, defer
from twisted.internet.defer import Deferred
+class MailSenderTest(unittest.TestCase):
+
+ def setUp(self):
+ self._cert_path = u'/some/cert/path'
+ self._keymanager_mock = mock()
+ self._remote_smtp_host = 'some.host.test'
+ self._remote_smtp_port = 1234
+
+ def tearDown(self):
+ unstub()
+
+ def test_iterates_over_recipients(self):
+ sender = MailSender('someone@somedomain.tld', self._keymanager_mock, self._cert_path, self._remote_smtp_host, self._remote_smtp_port)
+ input_mail = InputMail.from_dict(mail_dict())
+
+ when(OutgoingMail).send_message(any(), any()).thenAnswer(lambda: defer.succeed(None))
+
+ sender.sendmail(input_mail)
+
+ for recipient in flatten([input_mail.to, input_mail.cc, input_mail.bcc]):
+ verify(OutgoingMail).send_message(any(), recipient)
+
+
class LocalSmtpMailSenderTest(unittest.TestCase):
def setUp(self):
self.smtp = mock()