From 5b29217cdea1bfd487bfe8ee064559a88540ca58 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Wed, 4 Nov 2015 14:22:59 +0100 Subject: Change str email to twisted.mail.smtp.User - Issue #499 - leap.mail relies on this --- service/test/unit/adapter/services/test_mail_sender.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'service/test') diff --git a/service/test/unit/adapter/services/test_mail_sender.py b/service/test/unit/adapter/services/test_mail_sender.py index d8c33f17..20ddc2c6 100644 --- a/service/test/unit/adapter/services/test_mail_sender.py +++ b/service/test/unit/adapter/services/test_mail_sender.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see . from leap.mail.outgoing.service import OutgoingMail +from twisted.mail.smtp import User from twisted.trial import unittest from mockito import mock, when, verify, any, unstub @@ -24,6 +25,18 @@ from pixelated.support.functional import flatten from test.support.test_helper import mail_dict from twisted.internet import reactor, defer from twisted.internet.defer import Deferred +from mockito.matchers import Matcher + + +class TwistedSmtpUserCapture(Matcher): + + def __init__(self, username): + self._username = username + + def matches(self, arg): + return isinstance(arg, User) \ + and isinstance(arg.dest.addrstr, str) \ + and self._username == arg.dest.addrstr class MailSenderTest(unittest.TestCase): @@ -48,7 +61,7 @@ class MailSenderTest(unittest.TestCase): yield sender.sendmail(input_mail) for recipient in flatten([input_mail.to, input_mail.cc, input_mail.bcc]): - verify(OutgoingMail).send_message(any(), recipient) + verify(OutgoingMail).send_message(any(), TwistedSmtpUserCapture(recipient)) class LocalSmtpMailSenderTest(unittest.TestCase): -- cgit v1.2.3