diff options
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/adapter/mailstore/__init__.py | 3 | ||||
-rw-r--r-- | service/pixelated/adapter/mailstore/leap_mailstore.py | 9 | ||||
-rw-r--r-- | service/test/unit/adapter/mailstore/test_leap_mailstore.py | 15 |
3 files changed, 27 insertions, 0 deletions
diff --git a/service/pixelated/adapter/mailstore/__init__.py b/service/pixelated/adapter/mailstore/__init__.py index 2e7f132a..05d21e8b 100644 --- a/service/pixelated/adapter/mailstore/__init__.py +++ b/service/pixelated/adapter/mailstore/__init__.py @@ -22,6 +22,9 @@ class MailStore(object): def get_mails(self, mail_ids): pass + def all_mails(self): + pass + def delete_mail(self, mail_id): pass diff --git a/service/pixelated/adapter/mailstore/leap_mailstore.py b/service/pixelated/adapter/mailstore/leap_mailstore.py index 038163f3..1b72707f 100644 --- a/service/pixelated/adapter/mailstore/leap_mailstore.py +++ b/service/pixelated/adapter/mailstore/leap_mailstore.py @@ -77,6 +77,15 @@ class LeapMailStore(MailStore): pass @defer.inlineCallbacks + def all_mails(self): + mdocs = yield self.soledad.get_from_index('by-type', 'meta') + + mail_ids = map(lambda doc: doc.doc_id, mdocs) + + mails = yield self.get_mails(mail_ids) + defer.returnValue(mails) + + @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/unit/adapter/mailstore/test_leap_mailstore.py b/service/test/unit/adapter/mailstore/test_leap_mailstore.py index 36458d1e..26dd21f0 100644 --- a/service/test/unit/adapter/mailstore/test_leap_mailstore.py +++ b/service/test/unit/adapter/mailstore/test_leap_mailstore.py @@ -156,6 +156,21 @@ class TestLeapMailStore(TestCase): verify(self.soledad).put_doc(soledad_fdoc) self.assertTrue('new_tag' in soledad_fdoc.content['tags']) + @defer.inlineCallbacks + def test_all_mails(self): + first_mdoc_id, _ = self._add_mail_fixture_to_soledad('mbox00000000') + second_mdoc_id, _ = self._add_mail_fixture_to_soledad('mbox00000001') + when(self.soledad).get_from_index('by-type', 'meta').thenReturn(defer.succeed([self.doc_by_id[first_mdoc_id], self.doc_by_id[second_mdoc_id]])) + + store = LeapMailStore(self.soledad) + + mails = yield store.all_mails() + + self.assertIsNotNone(mails) + self.assertEqual(2, len(mails)) + self.assertEqual('Itaque consequatur repellendus provident sunt quia.', mails[0].subject) + self.assertEqual('Error illum dignissimos autem eos aspernatur.', mails[1].subject) + def _add_mail_fixture_to_soledad(self, mail_file): mail = self._load_mail_from_file(mail_file) msg = self._convert_mail_to_leap_message(mail) |