summaryrefslogtreecommitdiff
path: root/src/leap/mail/imap
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/mail/imap')
-rw-r--r--src/leap/mail/imap/mailbox.py12
-rw-r--r--src/leap/mail/imap/messages.py14
-rw-r--r--src/leap/mail/imap/tests/test_imap.py13
3 files changed, 10 insertions, 29 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py
index 0eff317..1412344 100644
--- a/src/leap/mail/imap/mailbox.py
+++ b/src/leap/mail/imap/mailbox.py
@@ -492,13 +492,8 @@ class IMAPMailbox(object):
:rtype: deferred with a generator that yields...
"""
- # For the moment our UID is sequential, so we
- # can treat them all the same.
- # Change this to the flag that twisted expects when we
- # switch to content-hash based index + local UID table.
-
- is_sequence = True if uid == 0 else False
-
+ # TODO implement sequence
+ # is_sequence = True if uid == 0 else False
# XXX DEBUG --- if you attempt to use the `getmail` utility under
# imap/tests, or muas like mutt, it will choke until we implement
# sequence numbers. This is an easy hack meanwhile.
@@ -583,7 +578,6 @@ class IMAPMailbox(object):
:rtype: tuple
"""
# is_sequence = True if uid == 0 else False
-
# XXX FIXME -----------------------------------------------------
# imap/tests, or muas like mutt, it will choke until we implement
# sequence numbers. This is an easy hack meanwhile.
@@ -672,7 +666,6 @@ class IMAPMailbox(object):
:rtype: tuple
"""
# TODO implement sequences
- # TODO how often is thunderbird doing this?
is_sequence = True if uid == 0 else False
if is_sequence:
raise NotImplementedError
@@ -730,7 +723,6 @@ class IMAPMailbox(object):
read-write.
"""
# TODO implement sequences
- # TODO how often is thunderbird doing this?
is_sequence = True if uid == 0 else False
if is_sequence:
raise NotImplementedError
diff --git a/src/leap/mail/imap/messages.py b/src/leap/mail/imap/messages.py
index 13943b1..4c6f10d 100644
--- a/src/leap/mail/imap/messages.py
+++ b/src/leap/mail/imap/messages.py
@@ -22,7 +22,7 @@ from twisted.mail import imap4
from twisted.internet import defer
from zope.interface import implements
-from leap.mail.utils import find_charset
+from leap.mail.utils import find_charset, CaseInsensitiveDict
logger = logging.getLogger(__name__)
@@ -208,18 +208,6 @@ class IMAPMessagePart(object):
return IMAPMessagePart(subpart)
-class CaseInsensitiveDict(dict):
- """
- A dictionary subclass that will allow case-insenstive key lookups.
- """
-
- def __setitem__(self, key, value):
- super(CaseInsensitiveDict, self).__setitem__(key.lower(), value)
-
- def __getitem__(self, key):
- return super(CaseInsensitiveDict, self).__getitem__(key.lower())
-
-
def _format_headers(headers, negate, *names):
# current server impl. expects content-type to be present, so if for
# some reason we do not have headers, we have to return at least that
diff --git a/src/leap/mail/imap/tests/test_imap.py b/src/leap/mail/imap/tests/test_imap.py
index c4f752b..af1bd69 100644
--- a/src/leap/mail/imap/tests/test_imap.py
+++ b/src/leap/mail/imap/tests/test_imap.py
@@ -25,8 +25,8 @@ XXX add authors from the original twisted tests.
@license: GPLv3, see included LICENSE file
"""
# XXX review license of the original tests!!!
-
import os
+import string
import types
@@ -38,6 +38,7 @@ from twisted.python import failure
from twisted import cred
from leap.mail.imap.mailbox import IMAPMailbox
+from leap.mail.imap.messages import CaseInsensitiveDict
from leap.mail.imap.tests.utils import IMAP4HelperMixin
@@ -74,8 +75,8 @@ class TestRealm:
#
# DEBUG ---
-#from twisted.internet.base import DelayedCall
-#DelayedCall.debug = True
+# from twisted.internet.base import DelayedCall
+# DelayedCall.debug = True
class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
@@ -810,7 +811,7 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
infile = util.sibpath(__file__, 'rfc822.message')
message = open(infile)
acc = self.server.theAccount
- mailbox_name = "root/subthing"
+ mailbox_name = "appendmbox/subthing"
def add_mailbox():
return acc.addMailbox(mailbox_name)
@@ -843,7 +844,7 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
uid, msg = fetched[0]
parsed = self.parser.parse(open(infile))
expected_body = parsed.get_payload()
- expected_headers = dict(parsed.items())
+ expected_headers = CaseInsensitiveDict(parsed.items())
def assert_flags(flags):
self.assertEqual(
@@ -860,7 +861,7 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
self.assertEqual(expected_body, gotbody)
def assert_headers(headers):
- self.assertItemsEqual(expected_headers, headers)
+ self.assertItemsEqual(map(string.lower, expected_headers), headers)
d = defer.maybeDeferred(msg.getFlags)
d.addCallback(assert_flags)