diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/services/mail_service.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/test_mail_service.py | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/service/pixelated/adapter/services/mail_service.py b/service/pixelated/adapter/services/mail_service.py index 9b7d20e8..4623a5eb 100644 --- a/service/pixelated/adapter/services/mail_service.py +++ b/service/pixelated/adapter/services/mail_service.py @@ -98,6 +98,8 @@ class MailService(object): if last_draft_ident: yield self.mail_store.delete_mail(last_draft_ident) sent_mail = yield self.mail_store.add_mail('SENT', mail.raw) + sent_mail.flags.add(Status.SEEN) + yield self.mail_store.update_mail(sent_mail) defer.returnValue(sent_mail) @defer.inlineCallbacks 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') |