diff options
Diffstat (limited to 'service/test/unit/adapter')
-rw-r--r-- | service/test/unit/adapter/test_mail_service.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/service/test/unit/adapter/test_mail_service.py b/service/test/unit/adapter/test_mail_service.py index de140997..043e3913 100644 --- a/service/test/unit/adapter/test_mail_service.py +++ b/service/test/unit/adapter/test_mail_service.py @@ -66,6 +66,10 @@ class TestMailService(unittest.TestCase): deferred_success = defer.succeed(None) when(self.mail_sender).sendmail(ANY()).thenReturn(deferred_success) + sent_mail = LeapMail('id', 'INBOX') + add_mail_deferral = defer.succeed(sent_mail) + when(self.mail_store).add_mail('SENT', ANY()).thenReturn(add_mail_deferral) + yield self.mail_service.send_mail({'ident': '12'}) verify(self.mail_sender).sendmail(mail) @@ -73,6 +77,23 @@ class TestMailService(unittest.TestCase): verify(self.mail_store).delete_mail('12') @defer.inlineCallbacks + def test_send_mail_marks_as_read(self): + mail = LeapMail('id', 'INBOX') + when(mail).raw = 'raw mail' + when(InputMail).from_dict(ANY()).thenReturn(mail) + when(self.mail_store).delete_mail('12').thenReturn(defer.succeed(None)) + when(self.mail_sender).sendmail(ANY()).thenReturn(defer.succeed(None)) + + sent_mail = LeapMail('id', 'INBOX') + add_mail_deferral = defer.succeed(sent_mail) + when(self.mail_store).add_mail('SENT', ANY()).thenReturn(add_mail_deferral) + + yield self.mail_service.send_mail({'ident': '12'}) + + self.assertIn(Status.SEEN, sent_mail.flags) + verify(self.mail_store).update_mail(sent_mail) + + @defer.inlineCallbacks def test_send_mail_does_not_delete_draft_on_error(self): when(InputMail).from_dict(ANY()).thenReturn('inputmail') |