diff options
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/integration/test_contacts.py | 24 | ||||
-rw-r--r-- | service/test/integration/test_delete_mail.py | 8 | ||||
-rw-r--r-- | service/test/integration/test_drafts.py | 6 | ||||
-rw-r--r-- | service/test/integration/test_mark_as_read_unread.py | 16 | ||||
-rw-r--r-- | service/test/integration/test_retrieve_attachment.py | 2 | ||||
-rw-r--r-- | service/test/integration/test_search.py | 32 | ||||
-rw-r--r-- | service/test/integration/test_soledad_querier.py | 8 | ||||
-rw-r--r-- | service/test/integration/test_tags.py | 14 |
8 files changed, 54 insertions, 56 deletions
diff --git a/service/test/integration/test_contacts.py b/service/test/integration/test_contacts.py index 3a510346..f9cde9e5 100644 --- a/service/test/integration/test_contacts.py +++ b/service/test/integration/test_contacts.py @@ -22,7 +22,7 @@ class ContactsTest(SoledadTestBase): def test_TO_CC_and_BCC_fields_are_being_searched(self): input_mail = MailBuilder().with_tags(['important']).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) d = self.get_contacts(query='recipient') @@ -35,7 +35,7 @@ class ContactsTest(SoledadTestBase): def test_FROM_address_is_being_searched(self): input_mail = MailBuilder().with_tags(['important']).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) d = self.get_contacts(query='Sender') @@ -45,10 +45,10 @@ class ContactsTest(SoledadTestBase): return d def test_trash_and_drafts_mailboxes_are_being_ignored(self): - self.client.add_multiple_to_mailbox(1, mailbox='INBOX', to='recipient@inbox.com') - self.client.add_multiple_to_mailbox(1, mailbox='DRAFTS', to='recipient@drafts.com') - self.client.add_multiple_to_mailbox(1, mailbox='SENT', to='recipient@sent.com') - self.client.add_multiple_to_mailbox(1, mailbox='TRASH', to='recipient@trash.com') + self.add_multiple_to_mailbox(1, mailbox='INBOX', to='recipient@inbox.com') + self.add_multiple_to_mailbox(1, mailbox='DRAFTS', to='recipient@drafts.com') + self.add_multiple_to_mailbox(1, mailbox='SENT', to='recipient@sent.com') + self.add_multiple_to_mailbox(1, mailbox='TRASH', to='recipient@trash.com') d = self.get_contacts(query='recipient') @@ -69,8 +69,8 @@ class ContactsTest(SoledadTestBase): formatted_input_mail.with_bcc('Recipient Carbon <recipient@bcc.com>') formatted_input_mail = formatted_input_mail.build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(formatted_input_mail) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(formatted_input_mail) d = self.get_contacts(query='Recipient') @@ -84,17 +84,17 @@ class ContactsTest(SoledadTestBase): def test_bounced_addresses_are_ignored(self): to_be_bounced = MailBuilder().with_to('this_mail_was_bounced@domain.com').build_input_mail() - self.client.add_mail_to_inbox(to_be_bounced) + self.add_mail_to_inbox(to_be_bounced) bounced_mail_template = MailBuilder().build_input_mail() - bounced_mail = self.client.mailboxes.inbox().add(bounced_mail_template) + bounced_mail = self.mailboxes.inbox().add(bounced_mail_template) bounced_mail.hdoc.content = self._bounced_mail_hdoc_content() bounced_mail.save() - self.client.search_engine.index_mail(bounced_mail) + self.search_engine.index_mail(bounced_mail) not_bounced_mail = MailBuilder( ).with_tags(['important']).with_to('this_mail_was_not@bounced.com').build_input_mail() - self.client.add_mail_to_inbox(not_bounced_mail) + self.add_mail_to_inbox(not_bounced_mail) d = self.get_contacts(query='this') diff --git a/service/test/integration/test_delete_mail.py b/service/test/integration/test_delete_mail.py index 91dc0e9e..8a7026f5 100644 --- a/service/test/integration/test_delete_mail.py +++ b/service/test/integration/test_delete_mail.py @@ -21,7 +21,7 @@ class DeleteMailTest(SoledadTestBase): def test_move_mail_to_trash_when_deleting(self): input_mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) inbox_mails = self.get_mails_by_tag('inbox') self.assertEquals(1, len(inbox_mails)) @@ -34,7 +34,7 @@ class DeleteMailTest(SoledadTestBase): self.assertEquals(1, len(trash_mails)) def test_delete_mail_when_trashing_mail_from_trash_mailbox(self): - mails = self.client.add_multiple_to_mailbox(1, 'trash') + mails = self.add_multiple_to_mailbox(1, 'trash') self.delete_mails([mails[0].ident]) trash_mails = self.get_mails_by_tag('trash') @@ -42,7 +42,7 @@ class DeleteMailTest(SoledadTestBase): self.assertEqual(0, len(trash_mails)) def test_move_mail_to_trash_when_delete_multiple(self): - mails = self.client.add_multiple_to_mailbox(5, 'inbox') + mails = self.add_multiple_to_mailbox(5, 'inbox') mail_idents = [m.ident for m in mails] self.delete_mails(mail_idents) @@ -51,7 +51,7 @@ class DeleteMailTest(SoledadTestBase): self.assertEquals(0, len(inbox)) def test_delete_permanently_when_mails_are_in_trash(self): - mails = self.client.add_multiple_to_mailbox(5, 'trash') + mails = self.add_multiple_to_mailbox(5, 'trash') self.delete_mails([m.ident for m in mails]) trash = self.get_mails_by_tag('trash') diff --git a/service/test/integration/test_drafts.py b/service/test/integration/test_drafts.py index a5901b67..cf96e0d9 100644 --- a/service/test/integration/test_drafts.py +++ b/service/test/integration/test_drafts.py @@ -27,7 +27,7 @@ class DraftsTest(SoledadTestBase): def test_post_sends_mail_and_deletes_previous_draft_if_it_exists(self): # act is if sending the mail by SMTP succeeded sendmail_deferred = Deferred() - when(self.client.mail_sender).sendmail(any()).thenReturn(sendmail_deferred) + when(self.mail_sender).sendmail(any()).thenReturn(sendmail_deferred) # creates one draft first_draft = MailBuilder().with_subject('First draft').build_json() @@ -56,7 +56,7 @@ class DraftsTest(SoledadTestBase): def test_post_sends_mail_even_when_draft_does_not_exist(self): # act is if sending the mail by SMTP succeeded sendmail_deferred = Deferred() - when(self.client.mail_sender).sendmail(any()).thenReturn(sendmail_deferred) + when(self.mail_sender).sendmail(any()).thenReturn(sendmail_deferred) first_draft = MailBuilder().with_subject('First draft').build_json() deferred_res = self.post_mail(first_draft) @@ -74,7 +74,7 @@ class DraftsTest(SoledadTestBase): return deferred_res def post_mail(self, data): - deferred_res, req = self.client.post('/mails', data) + deferred_res, req = self.post('/mails', data) deferred_res.callback(None) return deferred_res diff --git a/service/test/integration/test_mark_as_read_unread.py b/service/test/integration/test_mark_as_read_unread.py index cc09acec..f2f863a7 100644 --- a/service/test/integration/test_mark_as_read_unread.py +++ b/service/test/integration/test_mark_as_read_unread.py @@ -22,7 +22,7 @@ class MarkAsReadUnreadTest(SoledadTestBase): def test_mark_single_as_read(self): input_mail = MailBuilder().build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) mails = self.get_mails_by_tag('inbox') self.assertNotIn('read', mails[0].status) @@ -34,7 +34,7 @@ class MarkAsReadUnreadTest(SoledadTestBase): def test_mark_single_as_unread(self): input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) self.mark_many_as_unread([input_mail.ident]) mail = self.get_mails_by_tag('inbox')[0] @@ -45,8 +45,8 @@ class MarkAsReadUnreadTest(SoledadTestBase): input_mail = MailBuilder().with_status([Status.SEEN]).build_input_mail() input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(input_mail2) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) self.mark_many_as_unread([input_mail.ident, input_mail2.ident]) @@ -59,8 +59,8 @@ class MarkAsReadUnreadTest(SoledadTestBase): input_mail = MailBuilder().build_input_mail() input_mail2 = MailBuilder().build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(input_mail2) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) mails = self.get_mails_by_tag('inbox') @@ -79,8 +79,8 @@ class MarkAsReadUnreadTest(SoledadTestBase): input_mail = MailBuilder().build_input_mail() input_mail2 = MailBuilder().with_status([Status.SEEN]).build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(input_mail2) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) mails = self.get_mails_by_tag('inbox') diff --git a/service/test/integration/test_retrieve_attachment.py b/service/test/integration/test_retrieve_attachment.py index c81b684a..2c446b42 100644 --- a/service/test/integration/test_retrieve_attachment.py +++ b/service/test/integration/test_retrieve_attachment.py @@ -28,7 +28,7 @@ class RetrieveAttachmentTest(SoledadTestBase): 'phash': ident, 'content-type': 'text/plain; charset=US-ASCII; name="attachment_pequeno.txt"'} - self.client.add_document_to_soledad(attachment_dict) + self.add_document_to_soledad(attachment_dict) d = self.get_attachment(ident, 'base64') diff --git a/service/test/integration/test_search.py b/service/test/integration/test_search.py index 1de45967..9062bf67 100644 --- a/service/test/integration/test_search.py +++ b/service/test/integration/test_search.py @@ -21,7 +21,7 @@ class SearchTest(SoledadTestBase): def test_that_tags_returns_all_tags(self): input_mail = MailBuilder().with_tags(['important']).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) d = self.get_tags() @@ -37,7 +37,7 @@ class SearchTest(SoledadTestBase): def test_that_tags_are_filtered_by_query(self): input_mail = MailBuilder().with_tags(['ateu', 'catoa', 'luat', 'zuado']).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) d = self.get_tags(q=["at"], skipDefaultTags=["true"]) @@ -53,7 +53,7 @@ class SearchTest(SoledadTestBase): def test_tags_with_multiple_words_are_searchable(self): input_mail = MailBuilder().with_tags(['one tag four words']).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) first_page = self.get_mails_by_tag('"one tag four words"', page=1, window=1) @@ -61,7 +61,7 @@ class SearchTest(SoledadTestBase): def test_that_default_tags_are_ignorable(self): input_mail = MailBuilder().with_tags(['sometag']).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) d = self.get_tags(skipDefaultTags=["true"]) @@ -73,10 +73,10 @@ class SearchTest(SoledadTestBase): return d def test_tags_count(self): - self.client.add_multiple_to_mailbox(num=10, mailbox='inbox', flags=['\\Recent']) - self.client.add_multiple_to_mailbox(num=5, mailbox='inbox', flags=['\\Seen']) - self.client.add_multiple_to_mailbox(num=3, mailbox='inbox', flags=['\\Recent'], tags=['important', 'later']) - self.client.add_multiple_to_mailbox(num=1, mailbox='inbox', flags=['\\Seen'], tags=['important']) + self.add_multiple_to_mailbox(num=10, mailbox='inbox', flags=['\\Recent']) + self.add_multiple_to_mailbox(num=5, mailbox='inbox', flags=['\\Seen']) + self.add_multiple_to_mailbox(num=3, mailbox='inbox', flags=['\\Recent'], tags=['important', 'later']) + self.add_multiple_to_mailbox(num=1, mailbox='inbox', flags=['\\Seen'], tags=['important']) d = self.get_tags() @@ -91,8 +91,8 @@ class SearchTest(SoledadTestBase): def test_search_mails_different_window(self): input_mail = MailBuilder().build_input_mail() input_mail2 = MailBuilder().build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(input_mail2) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) first_page = self.get_mails_by_tag('inbox', page=1, window=1) @@ -101,8 +101,8 @@ class SearchTest(SoledadTestBase): def test_search_mails_with_multiple_pages(self): input_mail = MailBuilder().build_input_mail() input_mail2 = MailBuilder().build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(input_mail2) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) first_page = self.get_mails_by_tag('inbox', page=1, window=1) second_page = self.get_mails_by_tag('inbox', page=2, window=1) @@ -114,7 +114,7 @@ class SearchTest(SoledadTestBase): def test_page_zero_fetches_first_page(self): input_mail = MailBuilder().build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) page = self.get_mails_by_tag('inbox', page=0, window=1) self.assertEqual(page[0].ident, input_mail.ident) @@ -127,8 +127,8 @@ class SearchTest(SoledadTestBase): input_mail = MailBuilder().with_date('2014-10-15T15:15').build_input_mail() input_mail2 = MailBuilder().with_date('2014-10-15T15:16').build_input_mail() - self.client.add_mail_to_inbox(input_mail) - self.client.add_mail_to_inbox(input_mail2) + self.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail2) results = self.get_mails_by_tag('inbox') self.assertEqual(results[0].ident, input_mail2.ident) @@ -137,7 +137,7 @@ class SearchTest(SoledadTestBase): def test_search_base64_body(self): body = u'bl\xe1' input_mail = MailBuilder().with_body(body.encode('utf-8')).build_input_mail() - self.client.add_mail_to_inbox(input_mail) + self.add_mail_to_inbox(input_mail) results = self.search(body) self.assertGreater(len(results), 0, 'No results returned from search') diff --git a/service/test/integration/test_soledad_querier.py b/service/test/integration/test_soledad_querier.py index 00967d85..0d3cee41 100644 --- a/service/test/integration/test_soledad_querier.py +++ b/service/test/integration/test_soledad_querier.py @@ -25,9 +25,7 @@ class SoledadQuerierTest(SoledadTestBase, WithMsgFields): def setUp(self): SoledadTestBase.setUp(self) - self.soledad = self.client.soledad self.maxDiff = None - self.soledad_querier = self.client.soledad_querier def _get_empty_mailbox(self): return copy.deepcopy(self.EMPTY_MBOX) @@ -42,7 +40,7 @@ class SoledadQuerierTest(SoledadTestBase, WithMsgFields): return [m for m in self.soledad.get_from_index('by-type', 'mbox') if m.content['mbox'] == mailbox_name] def test_remove_dup_mailboxes_keeps_the_one_with_the_highest_last_uid(self): - self.client.add_multiple_to_mailbox(3, 'INBOX') # by now we already have one inbox with 3 mails + self.add_multiple_to_mailbox(3, 'INBOX') # by now we already have one inbox with 3 mails self._create_mailbox('INBOX') # now we have a duplicate # make sure we have two @@ -77,7 +75,7 @@ class SoledadQuerierTest(SoledadTestBase, WithMsgFields): self.assertEqual(1, len(mails)) def test_get_mails_by_chash(self): - mails = self.client.add_multiple_to_mailbox(3, 'INBOX') + mails = self.add_multiple_to_mailbox(3, 'INBOX') chashes = [mail.ident for mail in mails] fetched_mails = self.soledad_querier.mails(chashes) @@ -85,7 +83,7 @@ class SoledadQuerierTest(SoledadTestBase, WithMsgFields): self.assertEquals([m.as_dict() for m in fetched_mails], [m.as_dict() for m in mails]) def test_empty_or_bad_queries_are_handled(self): - self.client.add_multiple_to_mailbox(3, 'INBOX') + self.add_multiple_to_mailbox(3, 'INBOX') test_parameters = ['', 'undefined', None, 'none'] diff --git a/service/test/integration/test_tags.py b/service/test/integration/test_tags.py index 2e178a4d..aa20e88b 100644 --- a/service/test/integration/test_tags.py +++ b/service/test/integration/test_tags.py @@ -26,7 +26,7 @@ class TagsTest(SoledadTestBase): def test_add_tag_to_an_inbox_mail_and_query(self): mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(mail) + self.add_mail_to_inbox(mail) self.post_tags(mail.ident, self._tags_json(['IMPORTANT'])) @@ -38,13 +38,13 @@ class TagsTest(SoledadTestBase): def test_use_old_casing_when_same_tag_with_different_casing_is_posted(self): mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(mail) + self.add_mail_to_inbox(mail) self.post_tags(mail.ident, self._tags_json(['ImPoRtAnT'])) mails = self.get_mails_by_tag('ImPoRtAnT') self.assertEquals({'ImPoRtAnT'}, set(mails[0].tags)) another_mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(another_mail) + self.add_mail_to_inbox(another_mail) self.post_tags(another_mail.ident, self._tags_json(['IMPORTANT'])) mails = self.get_mails_by_tag('IMPORTANT') self.assertEquals(0, len(mails)) @@ -55,7 +55,7 @@ class TagsTest(SoledadTestBase): def test_tags_are_case_sensitive(self): mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(mail) + self.add_mail_to_inbox(mail) self.post_tags(mail.ident, self._tags_json(['ImPoRtAnT'])) @@ -70,7 +70,7 @@ class TagsTest(SoledadTestBase): def test_empty_tags_are_not_allowed(self): mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(mail) + self.add_mail_to_inbox(mail) self.post_tags(mail.ident, self._tags_json(['tag1', ' '])) @@ -80,11 +80,11 @@ class TagsTest(SoledadTestBase): def test_addition_of_reserved_tags_is_not_allowed(self): mail = MailBuilder().with_subject('Mail with tags').build_input_mail() - self.client.add_mail_to_inbox(mail) + self.add_mail_to_inbox(mail) for tag in SPECIAL_TAGS: response = self.post_tags(mail.ident, self._tags_json([tag.name.upper()])) self.assertEquals("None of the following words can be used as tags: %s" % tag.name, response) - mail = self.client.mailboxes.inbox().mail(mail.ident) + mail = self.mailboxes.inbox().mail(mail.ident) self.assertNotIn('drafts', mail.tags) |