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.py6
-rw-r--r--src/leap/mail/imap/messages.py7
-rw-r--r--src/leap/mail/imap/server.py16
-rw-r--r--src/leap/mail/imap/service/imap.py6
-rw-r--r--src/leap/mail/imap/tests/__init__.py20
-rw-r--r--src/leap/mail/imap/tests/test_imap.py20
-rw-r--r--src/leap/mail/imap/tests/test_imap_store_fetch.py12
-rw-r--r--src/leap/mail/imap/tests/walktree.py4
8 files changed, 53 insertions, 38 deletions
diff --git a/src/leap/mail/imap/mailbox.py b/src/leap/mail/imap/mailbox.py
index 4339bd2..c52a2e3 100644
--- a/src/leap/mail/imap/mailbox.py
+++ b/src/leap/mail/imap/mailbox.py
@@ -878,9 +878,9 @@ class IMAPMailbox(object):
# A better place for this would be the COPY/APPEND dispatcher
# in server.py, but qtreactor hangs when I do that, so this seems
# to work fine for now.
- #d.addCallback(lambda r: self.reactor.callLater(0, self.notify_new))
- #deferLater(self.reactor, 0, self._do_copy, message, d)
- #return d
+ # d.addCallback(lambda r: self.reactor.callLater(0, self.notify_new))
+ # deferLater(self.reactor, 0, self._do_copy, message, d)
+ # return d
d = self.collection.copy_msg(message.message,
self.collection.mbox_uuid)
diff --git a/src/leap/mail/imap/messages.py b/src/leap/mail/imap/messages.py
index 9af4c99..d1c7b93 100644
--- a/src/leap/mail/imap/messages.py
+++ b/src/leap/mail/imap/messages.py
@@ -217,10 +217,13 @@ def _format_headers(headers, negate, *names):
return {str('content-type'): str('')}
names = map(lambda s: s.upper(), names)
+
if negate:
- cond = lambda key: key.upper() not in names
+ def cond(key):
+ return key.upper() not in names
else:
- cond = lambda key: key.upper() in names
+ def cond(key):
+ return key.upper() in names
if isinstance(headers, list):
headers = dict(headers)
diff --git a/src/leap/mail/imap/server.py b/src/leap/mail/imap/server.py
index 2b670c1..050521a 100644
--- a/src/leap/mail/imap/server.py
+++ b/src/leap/mail/imap/server.py
@@ -122,9 +122,9 @@ class LEAPIMAPServer(imap4.IMAP4Server):
elif part.text:
_w(str(part) + ' ')
_f()
- return imap4.FileProducer(msg.getBodyFile()
- ).beginProducing(self.transport
- )
+ return imap4.FileProducer(
+ msg.getBodyFile()
+ ).beginProducing(self.transport)
elif part.mime:
hdrs = imap4._formatHeaders(msg.getHeaders(True))
@@ -151,10 +151,10 @@ class LEAPIMAPServer(imap4.IMAP4Server):
_fd.seek(0)
else:
_fd = fd
- return imap4.FileProducer(_fd
- # END PATCHED #########################3
- ).beginProducing(self.transport
- )
+ return imap4.FileProducer(
+ _fd
+ # END PATCHED #########################3
+ ).beginProducing(self.transport)
else:
mf = imap4.IMessageFile(msg, None)
if mf is not None:
@@ -459,7 +459,7 @@ class LEAPIMAPServer(imap4.IMAP4Server):
mailboxes.addCallback(self._cbSubscribed)
mailboxes.addCallback(
self._cbListWork, tag, sub, cmdName,
- ).addErrback(self._ebListWork, tag)
+ ).addErrback(self._ebListWork, tag)
def _cbSubscribed(self, mailboxes):
subscribed = [
diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py
index 92d05cc..c3ae59a 100644
--- a/src/leap/mail/imap/service/imap.py
+++ b/src/leap/mail/imap/service/imap.py
@@ -17,7 +17,6 @@
"""
IMAP service initialization
"""
-# TODO: leave only an implementor of IService in here
import logging
import os
@@ -29,13 +28,14 @@ from twisted.internet.protocol import ServerFactory
from twisted.mail import imap4
from twisted.python import log
-logger = logging.getLogger(__name__)
-
from leap.common.events import emit, catalog
from leap.common.check import leap_check
from leap.mail.imap.account import IMAPAccount
from leap.mail.imap.server import LEAPIMAPServer
+# TODO: leave only an implementor of IService in here
+
+logger = logging.getLogger(__name__)
DO_MANHOLE = os.environ.get("LEAP_MAIL_MANHOLE", None)
if DO_MANHOLE:
diff --git a/src/leap/mail/imap/tests/__init__.py b/src/leap/mail/imap/tests/__init__.py
index f3d5ca6..5cf60ed 100644
--- a/src/leap/mail/imap/tests/__init__.py
+++ b/src/leap/mail/imap/tests/__init__.py
@@ -1,4 +1,4 @@
-#-*- encoding: utf-8 -*-
+# -*- encoding: utf-8 -*-
"""
leap/email/imap/tests/__init__.py
----------------------------------
@@ -10,13 +10,6 @@ code, using twisted.trial, for testing leap_mx.
@copyright: © 2013 Kali Kaneko, see COPYLEFT file
"""
-__all__ = ['test_imap']
-
-
-def run():
- """xxx fill me in"""
- pass
-
import os
import u1db
@@ -25,11 +18,18 @@ from leap.common.testing.basetest import BaseLeapTest
from leap.soledad.client import Soledad
from leap.soledad.common.document import SoledadDocument
+__all__ = ['test_imap']
+
-#-----------------------------------------------------------------------------
+def run():
+ """xxx fill me in"""
+ pass
+
+# -----------------------------------------------------------------------------
# Some tests inherit from BaseSoledadTest in order to have a working Soledad
# instance in each test.
-#-----------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
+
class BaseSoledadIMAPTest(BaseLeapTest):
"""
diff --git a/src/leap/mail/imap/tests/test_imap.py b/src/leap/mail/imap/tests/test_imap.py
index af1bd69..62c3c41 100644
--- a/src/leap/mail/imap/tests/test_imap.py
+++ b/src/leap/mail/imap/tests/test_imap.py
@@ -387,8 +387,11 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
acc.addMailbox('this/mbox'),
acc.addMailbox('that/mbox')])
- dc1 = lambda: acc.subscribe('this/mbox')
- dc2 = lambda: acc.subscribe('that/mbox')
+ def dc1():
+ return acc.subscribe('this/mbox')
+
+ def dc2():
+ return acc.subscribe('that/mbox')
def login():
return self.client.login(TEST_USER, TEST_PASSWD)
@@ -439,7 +442,7 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
d1 = self.connected.addCallback(strip(add_mailbox))
d1.addCallback(strip(login))
d1.addCallback(strip(select))
- #d1.addErrback(self._ebGeneral)
+ # d1.addErrback(self._ebGeneral)
d2 = self.loopback()
@@ -668,9 +671,14 @@ class LEAPIMAP4ServerTestCase(IMAP4HelperMixin):
acc = self.server.theAccount
- dc1 = lambda: acc.addMailbox('root_subthing', creation_ts=42)
- dc2 = lambda: acc.addMailbox('root_another_thing', creation_ts=42)
- dc3 = lambda: acc.addMailbox('non_root_subthing', creation_ts=42)
+ def dc1():
+ return acc.addMailbox('root_subthing', creation_ts=42)
+
+ def dc2():
+ return acc.addMailbox('root_another_thing', creation_ts=42)
+
+ def dc3():
+ return acc.addMailbox('non_root_subthing', creation_ts=42)
def login():
return self.client.login(TEST_USER, TEST_PASSWD)
diff --git a/src/leap/mail/imap/tests/test_imap_store_fetch.py b/src/leap/mail/imap/tests/test_imap_store_fetch.py
index 6da8581..81f88fe 100644
--- a/src/leap/mail/imap/tests/test_imap_store_fetch.py
+++ b/src/leap/mail/imap/tests/test_imap_store_fetch.py
@@ -43,10 +43,14 @@ class StoreAndFetchTestCase(IMAP4HelperMixin):
self.connected.addCallback(
self._addSignedMessage).addCallback(
- lambda uid: self.function(
- uids, uid=uid) # do NOT use seq numbers!
- ).addCallback(result).addCallback(
- self._cbStopClient).addErrback(self._ebGeneral)
+ lambda uid: self.function(
+ uids, uid=uid
+ ) # do NOT use seq numbers!
+ ).addCallback(
+ result
+ ).addCallback(
+ self._cbStopClient
+ ).addErrback(self._ebGeneral)
d = loopback.loopbackTCP(self.server, self.client, noisy=False)
d.addCallback(lambda x: self.assertEqual(self.result, self.expected))
diff --git a/src/leap/mail/imap/tests/walktree.py b/src/leap/mail/imap/tests/walktree.py
index 695f487..f259a55 100644
--- a/src/leap/mail/imap/tests/walktree.py
+++ b/src/leap/mail/imap/tests/walktree.py
@@ -1,4 +1,4 @@
-#t -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
# walktree.py
# Copyright (C) 2013 LEAP
#
@@ -19,6 +19,7 @@ Tests for the walktree module.
"""
import os
import sys
+import pprint
from email import parser
from leap.mail import walk as W
@@ -118,7 +119,6 @@ if DEBUG and DO_CHECK:
print "Structure: OK"
-import pprint
print
print "RAW DOCS"
pprint.pprint(raw_docs)