diff options
author | Eli Mydlarz <eli.mydlarz@gmail.com> | 2015-08-20 15:59:54 +1000 |
---|---|---|
committer | Robin Doherty <rdoherty@gmail.com> | 2015-08-21 15:30:58 +1000 |
commit | 912c3e5cb9a11273d7a4d33c0e7dfb438801a184 (patch) | |
tree | cd56c2fca8e8be3fe4305f264882351b618c9b3f /service/test/unit/adapter | |
parent | e92431a4d7b71418f354fa9c3a6d466e2d113fa9 (diff) |
Eli: Marking sent emails as read
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') |