summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-07-28 15:50:38 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:29 +0200
commit9ba07cc943f1d85664b70546404ee26b1313dcee (patch)
tree36e82c087fb112f244559e0d1d136ab27eec378f /service
parentff739a697af362647c17a4010984439a03b673df (diff)
Added delete_mailbox to leap mail store.
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/mailstore/__init__.py3
-rw-r--r--service/pixelated/adapter/mailstore/leap_mailstore.py5
-rw-r--r--service/test/integration/test_leap_mailstore.py3
-rw-r--r--service/test/unit/adapter/mailstore/test_leap_mailstore.py14
4 files changed, 24 insertions, 1 deletions
diff --git a/service/pixelated/adapter/mailstore/__init__.py b/service/pixelated/adapter/mailstore/__init__.py
index 6983194d..ab7bfb94 100644
--- a/service/pixelated/adapter/mailstore/__init__.py
+++ b/service/pixelated/adapter/mailstore/__init__.py
@@ -40,6 +40,9 @@ class MailStore(object):
def add_mailbox(self, mailbox_name):
pass
+ def delete_mailbox(self, mailbox_name):
+ pass
+
def get_mailbox_mail_ids(self, mailbox_name):
pass
diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py
index ee40e03b..70c19bca 100644
--- a/service/pixelated/adapter/mailstore/leap_mailstore.py
+++ b/service/pixelated/adapter/mailstore/leap_mailstore.py
@@ -119,6 +119,11 @@ class LeapMailStore(MailStore):
defer.returnValue(mail_ids)
@defer.inlineCallbacks
+ def delete_mailbox(self, mailbox_name):
+ mbx_wrapper = yield self._get_or_create_mailbox(mailbox_name)
+ yield SoledadMailAdaptor().delete_mbox(self.soledad, mbx_wrapper)
+
+ @defer.inlineCallbacks
def _leap_message_to_leap_mail(self, mail_id, message, include_body):
if include_body:
body = (yield message._wrapper.get_body(self.soledad)).raw
diff --git a/service/test/integration/test_leap_mailstore.py b/service/test/integration/test_leap_mailstore.py
index 1cca6903..d4589a1a 100644
--- a/service/test/integration/test_leap_mailstore.py
+++ b/service/test/integration/test_leap_mailstore.py
@@ -71,11 +71,12 @@ class LeapMailStoreTest(SoledadTestBase):
def test_get_mailbox_mail_ids(self):
mail = _load_mail_from_file('mbox00000000')
yield self.store.add_mailbox('INBOX')
- yield self.store.add_mail('INBOX', mail.as_string())
+ mail = yield self.store.add_mail('INBOX', mail.as_string())
mails = yield self.store.get_mailbox_mail_ids('INBOX')
self.assertEqual(1, len(mails))
+ self.assertEqual(mail.mail_id, mails[0])
@defer.inlineCallbacks
def _create_mail_in_soledad(self, mail):
diff --git a/service/test/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py
index f860455d..ec68f3b7 100644
--- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py
+++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py
@@ -222,6 +222,17 @@ class TestLeapMailStore(TestCase):
self.assertEqual(1, len(mail_ids))
self.assertEqual(mdoc_id, mail_ids[0])
+ @defer.inlineCallbacks
+ def test_delete_mailbox(self):
+ _, mbox_soledad_doc = self._mock_get_mailbox('INBOX')
+ store = LeapMailStore(self.soledad)
+ when(self.soledad).delete_doc(mbox_soledad_doc).thenReturn(defer.succeed(None))
+
+ yield store.delete_mailbox('INBOX')
+
+ verify(self.soledad).delete_doc(self.doc_by_id[mbox_soledad_doc.doc_id])
+ # should also verify index is updated
+
def _assert_message_docs_created(self, expected_message, actual_message):
wrapper = expected_message.get_wrapper()
@@ -237,6 +248,9 @@ class TestLeapMailStore(TestCase):
mbox = MailboxWrapper(doc_id=self.mbox_uuid, mbox=mailbox_name, uuid=self.mbox_uuid)
soledad_doc = SoledadDocument(self.mbox_uuid, json=json.dumps(mbox.serialize()))
when(self.soledad).get_from_index('by-type-and-mbox', 'mbox', mailbox_name).thenReturn(defer.succeed([soledad_doc]))
+ self._mock_soledad_doc(self.mbox_uuid, mbox)
+
+ return mbox, soledad_doc
def _add_mail_fixture_to_soledad(self, mail_file):
mail = self._load_mail_from_file(mail_file)