summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-05-24 14:25:19 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2017-05-24 14:59:55 +0200
commitcf610930f7a9b56b0378920bfdd4263f490b5cb3 (patch)
treec6afdc78a8d07fd5d32de6482ef186fa8436f74a
parent37b25fd88400df8cc726470b5d897111f2373b96 (diff)
[tests] fix tests
-rw-r--r--src/leap/bitmask/mail/incoming/service.py5
-rw-r--r--tests/integration/mail/adaptors/test_soledad_adaptor.py6
-rw-r--r--tests/integration/mail/imap/test_imap.py23
-rw-r--r--tests/integration/mail/test_mail.py15
4 files changed, 26 insertions, 23 deletions
diff --git a/src/leap/bitmask/mail/incoming/service.py b/src/leap/bitmask/mail/incoming/service.py
index 6a5d7fe3..00e7ee4f 100644
--- a/src/leap/bitmask/mail/incoming/service.py
+++ b/src/leap/bitmask/mail/incoming/service.py
@@ -44,7 +44,7 @@ from leap.common.mail import get_email_charset
from leap.bitmask.keymanager import errors as keymanager_errors
from leap.bitmask.mail.adaptors import soledad_indexes as fields
from leap.bitmask.mail.generator import Generator
-from leap.bitmask.mail.utils import json_loads, empty
+from leap.bitmask.mail.utils import json_loads
from leap.soledad.client import Soledad
from leap.soledad.common.crypto import ENC_SCHEME_KEY, ENC_JSON_KEY
from leap.soledad.common.errors import InvalidAuthTokenError
@@ -832,9 +832,6 @@ class IncomingMail(Service):
def msgSavedCallback(result):
- #if empty(result):
- #return
-
def signal_deleted(doc_id):
emit_async(catalog.MAIL_MSG_DELETED_INCOMING,
self._userid)
diff --git a/tests/integration/mail/adaptors/test_soledad_adaptor.py b/tests/integration/mail/adaptors/test_soledad_adaptor.py
index 72b0be8f..14e0e407 100644
--- a/tests/integration/mail/adaptors/test_soledad_adaptor.py
+++ b/tests/integration/mail/adaptors/test_soledad_adaptor.py
@@ -396,9 +396,9 @@ class SoledadMailAdaptorTestCase(SoledadTestMixin):
msg = adaptor.get_msg_from_string(MessageClass, raw)
def check_create_result(created):
- # that's one mdoc, one hdoc, one fdoc, one cdoc
- self.assertEqual(len(created), 4)
- for doc in created:
+ # that's the wrapper
+ self.assertEqual(created.__class__.__name__, 'MessageWrapper')
+ for doc in [created.mdoc, created.fdoc, created.hdoc]:
self.assertTrue(
doc.__class__.__name__,
"SoledadDocument")
diff --git a/tests/integration/mail/imap/test_imap.py b/tests/integration/mail/imap/test_imap.py
index 6f8eec2a..ea86125d 100644
--- a/tests/integration/mail/imap/test_imap.py
+++ b/tests/integration/mail/imap/test_imap.py
@@ -81,6 +81,9 @@ class TestRealm:
# DelayedCall.debug = True
+DEFAULT_MBOXES = ['INBOX', 'Sent']
+
+
class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
"""
@@ -138,8 +141,8 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
def _cbTestCreate(self, mailboxes, succeed, fail):
self.assertEqual(self.result, [1] * len(succeed) + [0] * len(fail))
- answers = ([u'INBOX', u'testbox', u'test/box', u'test',
- u'test/box/box', 'foobox'])
+ answers = (DEFAULT_MBOXES + [u'testbox', u'test/box', u'test',
+ u'test/box/box', 'foobox'])
self.assertEqual(sorted(mailboxes), sorted([a for a in answers]))
def testDelete(self):
@@ -165,7 +168,7 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
d = defer.gatherResults([d1, d2])
d.addCallback(lambda _: acc.list_all_mailbox_names())
d.addCallback(lambda mboxes: self.assertEqual(
- mboxes, ['INBOX']))
+ set(mboxes), set(DEFAULT_MBOXES)))
return d
def testIllegalInboxDelete(self):
@@ -288,7 +291,8 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
d.addCallback(lambda _:
self.server.theAccount.account.list_all_mailbox_names())
d.addCallback(lambda mboxes:
- self.assertItemsEqual(mboxes, ['INBOX', 'newname']))
+ self.assertItemsEqual(
+ mboxes, DEFAULT_MBOXES + ['newname']))
return d
def testIllegalInboxRename(self):
@@ -345,7 +349,7 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
return d.addCallback(self._cbTestHierarchicalRename)
def _cbTestHierarchicalRename(self, mailboxes):
- expected = ['INBOX', 'newname/m1', 'newname/m2']
+ expected = DEFAULT_MBOXES + ['newname/m1', 'newname/m2']
self.assertEqual(sorted(mailboxes), sorted([s for s in expected]))
def testSubscribe(self):
@@ -1002,14 +1006,11 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
def add_messages():
d = self.mailbox.addMessage(
- 'test 1', flags=('\\Deleted', 'AnotherFlag'),
- notify_just_mdoc=False)
+ 'test 1', flags=('\\Deleted', 'AnotherFlag'))
d.addCallback(lambda _: self.mailbox.addMessage(
- 'test 2', flags=('AnotherFlag',),
- notify_just_mdoc=False))
+ 'test 2', flags=('AnotherFlag',)))
d.addCallback(lambda _: self.mailbox.addMessage(
- 'test 3', flags=('\\Deleted',),
- notify_just_mdoc=False))
+ 'test 3', flags=('\\Deleted',)))
return d
def expunge():
diff --git a/tests/integration/mail/test_mail.py b/tests/integration/mail/test_mail.py
index 637340d5..42b4478e 100644
--- a/tests/integration/mail/test_mail.py
+++ b/tests/integration/mail/test_mail.py
@@ -313,6 +313,9 @@ class MessageCollectionTestCase(SoledadTestMixin, CollectionMixin):
pass
+DEFAULT_MBOXES = ['INBOX', 'Sent']
+
+
class AccountTestCase(SoledadTestMixin):
"""
Tests for the Account class.
@@ -329,12 +332,13 @@ class AccountTestCase(SoledadTestMixin):
return d
def _test_add_mailbox_cb(self, mboxes):
- expected = ['INBOX', 'TestMailbox']
+ expected = DEFAULT_MBOXES + ['TestMailbox']
self.assertItemsEqual(mboxes, expected)
def test_delete_mailbox(self):
acc = self.get_account('some_user_id')
- d = acc.callWhenReady(lambda _: acc.delete_mailbox("Inbox"))
+ d = acc.callWhenReady(lambda _: acc.delete_mailbox('Inbox'))
+ d.addCallback(lambda _: acc.delete_mailbox('Sent'))
d.addCallback(lambda _: acc.list_all_mailbox_names())
d.addCallback(self._test_delete_mailbox_cb)
return d
@@ -353,7 +357,7 @@ class AccountTestCase(SoledadTestMixin):
return d
def _test_rename_mailbox_cb(self, mboxes):
- expected = ['INBOX', 'RenamedMailbox']
+ expected = DEFAULT_MBOXES + ['RenamedMailbox']
self.assertItemsEqual(mboxes, expected)
def test_get_all_mailboxes(self):
@@ -368,8 +372,9 @@ class AccountTestCase(SoledadTestMixin):
return d
def _test_get_all_mailboxes_cb(self, mailboxes):
- expected = ["INBOX", "OneMailbox", "TwoMailbox", "ThreeMailbox",
- "anotherthing", "anotherthing2"]
+ expected = DEFAULT_MBOXES + [
+ "OneMailbox", "TwoMailbox", "ThreeMailbox", "anotherthing",
+ "anotherthing2"]
names = [m.mbox for m in mailboxes]
self.assertItemsEqual(names, expected)