diff options
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/integration/test_mark_as_read_unread.py | 33 | ||||
-rw-r--r-- | service/test/support/integration/app_test_client.py | 2 | ||||
-rw-r--r-- | service/test/unit/adapter/test_draft_service.py | 15 |
3 files changed, 27 insertions, 23 deletions
diff --git a/service/test/integration/test_mark_as_read_unread.py b/service/test/integration/test_mark_as_read_unread.py index b2249b54..48879e4a 100644 --- a/service/test/integration/test_mark_as_read_unread.py +++ b/service/test/integration/test_mark_as_read_unread.py @@ -25,35 +25,37 @@ class MarkAsReadUnreadTest(SoledadTestBase): @defer.inlineCallbacks def test_mark_single_as_read(self): input_mail = MailBuilder().build_input_mail() - yield self.add_mail_to_inbox(input_mail) + mail = yield self.add_mail_to_inbox(input_mail) mails = yield self.get_mails_by_tag('inbox') self.assertNotIn('read', mails[0].status) - yield self.mark_many_as_read([input_mail.ident]) + yield self.mark_many_as_read([mail.ident]) mails = yield self.get_mails_by_tag('inbox') self.assertIn('read', mails[0].status) @defer.inlineCallbacks def test_mark_single_as_unread(self): - input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail() - yield self.add_mail_to_inbox(input_mail) + input_mail = MailBuilder().build_input_mail() + mail = yield self.add_mail_to_inbox(input_mail) + yield self.mark_many_as_read([mail.ident]) - yield self.mark_many_as_unread([input_mail.ident]) - mail = (yield self.get_mails_by_tag('inbox'))[0] + yield self.mark_many_as_unread([mail.ident]) + result = (yield self.get_mails_by_tag('inbox'))[0] - self.assertNotIn('read', mail.status) + self.assertNotIn('read', result.status) @defer.inlineCallbacks def test_mark_many_mails_as_unread(self): input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail() input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail() - yield self.add_mail_to_inbox(input_mail) - yield self.add_mail_to_inbox(input_mail2) + mail1 = yield self.add_mail_to_inbox(input_mail) + mail2 = yield self.add_mail_to_inbox(input_mail2) + yield self.mark_many_as_read([mail1.ident, mail2.ident]) - yield self.mark_many_as_unread([input_mail.ident, input_mail2.ident]) + yield self.mark_many_as_unread([mail1.ident, mail2.ident]) mails = yield self.get_mails_by_tag('inbox') @@ -73,7 +75,7 @@ class MarkAsReadUnreadTest(SoledadTestBase): self.assertNotIn('read', mails[0].status) self.assertNotIn('read', mails[1].status) - yield self.mark_many_as_read([input_mail.ident, input_mail2.ident]) + yield self.mark_many_as_read([mails[0].ident, mails[1].ident]) mails = yield self.get_mails_by_tag('inbox') @@ -82,11 +84,12 @@ class MarkAsReadUnreadTest(SoledadTestBase): @defer.inlineCallbacks def test_mark_mixed_status_as_read(self): - input_mail = MailBuilder().build_input_mail() - input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail() + input_mail = MailBuilder().with_subject('first').build_input_mail() + input_mail2 = MailBuilder().with_subject('second').build_input_mail() yield self.add_mail_to_inbox(input_mail) - yield self.add_mail_to_inbox(input_mail2) + mail2 = yield self.add_mail_to_inbox(input_mail2) + yield self.mark_many_as_read([mail2.ident]) mails = yield self.get_mails_by_tag('inbox') @@ -95,7 +98,7 @@ class MarkAsReadUnreadTest(SoledadTestBase): self.assertEquals(1, len(unread_mails)) self.assertEquals(1, len(read_mails)) - yield self.mark_many_as_read([input_mail.ident, input_mail2.ident]) + yield self.mark_many_as_read([mails[0].ident, mails[1].ident]) mails = yield self.get_mails_by_tag('inbox') diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index ee305c69..31ffcd77 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -78,7 +78,7 @@ class AppTestClient(object): self.account = IMAPAccount(self.ACCOUNT, self.soledad, account_ready_cb) yield account_ready_cb self.mailboxes = Mailboxes(self.account, self.mail_store, self.soledad_querier, self.search_engine) - self.draft_service = DraftService(self.mailboxes) + self.draft_service = DraftService(self.mail_store) self.mail_service = self._create_mail_service(self.mailboxes, self.mail_sender, self.mail_store, self.soledad_querier, self.search_engine) mails = yield self.mail_service.all_mails() diff --git a/service/test/unit/adapter/test_draft_service.py b/service/test/unit/adapter/test_draft_service.py index 79eca5f6..c2b7cd93 100644 --- a/service/test/unit/adapter/test_draft_service.py +++ b/service/test/unit/adapter/test_draft_service.py @@ -1,4 +1,6 @@ import unittest +from twisted.internet import defer +from pixelated.adapter.mailstore.leap_mailstore import LeapMail from pixelated.adapter.model.mail import InputMail from pixelated.adapter.services.draft_service import DraftService @@ -10,21 +12,20 @@ class DraftServiceTest(unittest.TestCase): def setUp(self): self.mailboxes = mock() - self.drafts_mailbox = mock() - self.draft_service = DraftService(self.mailboxes) - self.mailboxes.drafts = self.drafts_mailbox + self.mail_store = mock() + self.draft_service = DraftService(self.mail_store) def test_add_draft(self): mail = InputMail() self.draft_service.create_draft(mail) - verify(self.drafts_mailbox).add(mail) + verify(self.mail_store).add_mail('DRAFTS', mail.raw) def test_update_draft(self): mail = InputMail.from_dict(test_helper.mail_dict()) - when(self.drafts_mailbox).add(mail).thenReturn(mail) + when(self.mail_store).add_mail('DRAFTS', mail.raw).thenReturn(defer.succeed(LeapMail('id', 'DRAFTS'))) self.draft_service.update_draft(mail.ident, mail) - inorder.verify(self.drafts_mailbox).add(mail) - inorder.verify(self.drafts_mailbox).remove(mail.ident) + inorder.verify(self.mail_store).add_mail('DRAFTS', mail.raw) + inorder.verify(self.mail_store).delete_mail(mail.ident) |