diff options
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/integration/test_delete_mail.py | 5 | ||||
-rw-r--r-- | service/test/support/integration/app_test_client.py | 27 | ||||
-rw-r--r-- | service/test/unit/adapter/mailstore/test_leap_mailstore.py | 8 |
3 files changed, 26 insertions, 14 deletions
diff --git a/service/test/integration/test_delete_mail.py b/service/test/integration/test_delete_mail.py index 58c9e33b..9e5143e1 100644 --- a/service/test/integration/test_delete_mail.py +++ b/service/test/integration/test_delete_mail.py @@ -22,12 +22,12 @@ class DeleteMailTest(SoledadTestBase): @defer.inlineCallbacks def test_move_mail_to_trash_when_deleting(self): input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - yield self.add_mail_to_inbox(input_mail) + mail = yield self.add_mail_to_inbox(input_mail) inbox_mails = yield self.get_mails_by_tag('inbox') self.assertEquals(1, len(inbox_mails)) - yield self.delete_mail(input_mail.ident) + yield self.delete_mail(mail.mail_id) inbox_mails = yield self.get_mails_by_tag('inbox') self.assertEquals(0, len(inbox_mails)) @@ -45,6 +45,7 @@ class DeleteMailTest(SoledadTestBase): @defer.inlineCallbacks def test_move_mail_to_trash_when_delete_multiple(self): + yield self.add_multiple_to_mailbox(1, 'trash') mails = yield self.add_multiple_to_mailbox(5, 'inbox') mail_idents = [m.ident for m in mails] diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 28d378b3..ee305c69 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -141,24 +141,33 @@ class AppTestClient(object): @defer.inlineCallbacks def add_mail_to_inbox(self, input_mail): - inbox = yield self.mailboxes.inbox - mail = yield inbox.add(input_mail) - if input_mail.tags: - mail.update_tags(input_mail.tags) - self.search_engine.index_mail(mail) + mail = yield self.mail_store.add_mail('INBOX', input_mail.raw) + defer.returnValue(mail) + # inbox = yield self.mailboxes.inbox + # mail = yield inbox.add(input_mail) + # if input_mail.tags: + # mail.update_tags(input_mail.tags) + # self.search_engine.index_mail(mail) @defer.inlineCallbacks def add_multiple_to_mailbox(self, num, mailbox='', flags=[], tags=[], to='recipient@to.com', cc='recipient@cc.com', bcc='recipient@bcc.com'): mails = [] + yield self.mail_store.add_mailbox(mailbox) for _ in range(num): builder = MailBuilder().with_status(flags).with_tags(tags).with_to(to).with_cc(cc).with_bcc(bcc) builder.with_body(str(random.random())) input_mail = builder.build_input_mail() - mbx = yield self.mailboxes._create_or_get(mailbox) - mail = yield mbx.add(input_mail) + mail = yield self.mail_store.add_mail(mailbox, input_mail.raw) + if tags: + mail.tags.add(tags) + yield self.mail_store.update_mail(mail) mails.append(mail) - mail.update_tags(input_mail.tags) if tags else None - self.search_engine.index_mails(mails) if tags else None + + # mbx = yield self.mailboxes._create_or_get(mailbox) + # mail = yield mbx.add(input_mail) + # mails.append(mail) + # mail.update_tags(input_mail.tags) if tags else None + # self.search_engine.index_mails(mails) if tags else None defer.returnValue(mails) diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py index 4565cc6d..429f1683 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py @@ -23,7 +23,7 @@ from twisted.internet.defer import FirstError from twisted.trial.unittest import TestCase from leap.mail import constants from twisted.internet import defer -from mockito import mock, when, verify, any +from mockito import mock, when, verify, any as ANY import test.support.mockito from leap.mail.adaptors.soledad import SoledadMailAdaptor, MailboxWrapper import pkg_resources @@ -31,7 +31,7 @@ from leap.mail.mail import Message from pixelated.adapter.mailstore import underscore_uuid from pixelated.adapter.mailstore.leap_mailstore import LeapMailStore, LeapMail - +import test.support.mockito class TestLeapMail(TestCase): def test_leap_mail(self): @@ -203,8 +203,9 @@ class TestLeapMailStore(TestCase): def test_add_mailbox(self): when(self.soledad).list_indexes().thenReturn(defer.succeed(MAIL_INDEXES)).thenReturn(defer.succeed(MAIL_INDEXES)) when(self.soledad).get_from_index('by-type-and-mbox', 'mbox', 'TEST').thenReturn(defer.succeed([])) - when(self.soledad).create_doc(any()).thenReturn(defer.succeed(None)) self._mock_create_doc(self.mbox_uuid, MailboxWrapper(mbox='TEST')) + when(self.soledad).get_doc(self.mbox_uuid).thenAnswer(lambda: defer.succeed(self.doc_by_id[self.mbox_uuid])) + when(self.soledad).put_doc(ANY()).thenAnswer(lambda: defer.succeed(None)) store = LeapMailStore(self.soledad) mbox = yield store.add_mailbox('TEST') @@ -212,6 +213,7 @@ class TestLeapMailStore(TestCase): self.assertIsNotNone(mbox) self.assertEqual(self.mbox_uuid, mbox.doc_id) self.assertEqual('TEST', mbox.mbox) + self.assertIsNotNone(mbox.uuid) # assert index got updated @defer.inlineCallbacks |