diff options
author | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-07-22 09:37:24 +0000 |
---|---|---|
committer | Folker Bernitt <fbernitt@thoughtworks.com> | 2015-08-11 17:00:27 +0200 |
commit | 414f210a908427da10a90fb4c8c83d58e1496b26 (patch) | |
tree | 45b6eb2e12a15232f732993658cbe9276cd4b4cc /service/test | |
parent | cb0c0b7905be251191e9ef78908d84ed617283c8 (diff) |
Fixed test_delete_mail integration test.
Diffstat (limited to 'service/test')
-rw-r--r-- | service/test/integration/test_delete_mail.py | 30 | ||||
-rw-r--r-- | service/test/support/integration/app_test_client.py | 10 |
2 files changed, 24 insertions, 16 deletions
diff --git a/service/test/integration/test_delete_mail.py b/service/test/integration/test_delete_mail.py index 18bae44a..58c9e33b 100644 --- a/service/test/integration/test_delete_mail.py +++ b/service/test/integration/test_delete_mail.py @@ -19,42 +19,46 @@ from test.support.integration import SoledadTestBase, MailBuilder 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() - self.add_mail_to_inbox(input_mail) + yield self.add_mail_to_inbox(input_mail) - inbox_mails = self.get_mails_by_tag('inbox') + inbox_mails = yield self.get_mails_by_tag('inbox') self.assertEquals(1, len(inbox_mails)) - self.delete_mail(input_mail.ident) + yield self.delete_mail(input_mail.ident) - inbox_mails = self.get_mails_by_tag('inbox') + inbox_mails = yield self.get_mails_by_tag('inbox') self.assertEquals(0, len(inbox_mails)) - trash_mails = self.get_mails_by_tag('trash') + trash_mails = yield self.get_mails_by_tag('trash') self.assertEquals(1, len(trash_mails)) @defer.inlineCallbacks def test_delete_mail_when_trashing_mail_from_trash_mailbox(self): mails = yield self.add_multiple_to_mailbox(1, 'trash') - self.delete_mails([mails[0].ident]) + yield self.delete_mails([mails[0].ident]) - trash_mails = self.get_mails_by_tag('trash') + trash_mails = yield self.get_mails_by_tag('trash') self.assertEqual(0, len(trash_mails)) + @defer.inlineCallbacks def test_move_mail_to_trash_when_delete_multiple(self): - mails = self.add_multiple_to_mailbox(5, 'inbox') + mails = yield self.add_multiple_to_mailbox(5, 'inbox') mail_idents = [m.ident for m in mails] - self.delete_mails(mail_idents) + yield self.delete_mails(mail_idents) - inbox = self.get_mails_by_tag('inbox') + inbox = yield self.get_mails_by_tag('inbox') self.assertEquals(0, len(inbox)) + @defer.inlineCallbacks def test_delete_permanently_when_mails_are_in_trash(self): - mails = self.add_multiple_to_mailbox(5, 'trash') - self.delete_mails([m.ident for m in mails]) + mails = yield self.add_multiple_to_mailbox(5, 'trash') + mail_idents = [m.ident for m in mails] - trash = self.get_mails_by_tag('trash') + yield self.delete_mails(mail_idents) + trash = yield self.get_mails_by_tag('trash') self.assertEquals(0, len(trash)) diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py index 9acef1bd..da237284 100644 --- a/service/test/support/integration/app_test_client.py +++ b/service/test/support/integration/app_test_client.py @@ -20,6 +20,8 @@ import os import shutil import time import uuid +import random + from leap.mail.imap.account import IMAPAccount from leap.soledad.client import Soledad @@ -140,7 +142,9 @@ class AppTestClient(object): def add_multiple_to_mailbox(self, num, mailbox='', flags=[], tags=[], to='recipient@to.com', cc='recipient@cc.com', bcc='recipient@bcc.com'): mails = [] for _ in range(num): - input_mail = MailBuilder().with_status(flags).with_tags(tags).with_to(to).with_cc(cc).with_bcc(bcc).build_input_mail() + 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) mails.append(mail) @@ -202,11 +206,11 @@ class AppTestClient(object): def delete_mail(self, mail_ident): res, req = self.delete("/mail/%s" % mail_ident) - return req + return res def delete_mails(self, idents): res, req = self.post("/mails/delete", json.dumps({'idents': idents})) - return req + return res def mark_many_as_unread(self, idents): res, req = self.post('/mails/unread', json.dumps({'idents': idents})) |