summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-08-06 09:56:12 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:32 +0200
commit8b38782075fab1410a5f45c79c2cc252ff3d84db (patch)
tree8e91b31733ebc7ac288719c45562f7af580df7dc
parentf4541e455e624747f04d35b3567c40147942c9ce (diff)
Added move mail to indexing mail store.
-rw-r--r--service/pixelated/adapter/mailstore/searchable_mailstore.py7
-rw-r--r--service/test/unit/adapter/mailstore/test_searchable_mailstore.py12
2 files changed, 19 insertions, 0 deletions
diff --git a/service/pixelated/adapter/mailstore/searchable_mailstore.py b/service/pixelated/adapter/mailstore/searchable_mailstore.py
index efb611fb..7339bd18 100644
--- a/service/pixelated/adapter/mailstore/searchable_mailstore.py
+++ b/service/pixelated/adapter/mailstore/searchable_mailstore.py
@@ -47,6 +47,13 @@ class SearchableMailStore(object): # implementes MailStore
yield self._delegate.update_mail(mail)
self._search_engine.index_mail(mail)
+ @defer.inlineCallbacks
+ def move_mail_to_mailbox(self, mail_id, mailbox_name):
+ moved_mail = yield self._delegate.move_mail_to_mailbox(mail_id, mailbox_name)
+ self._search_engine.remove_from_index(mail_id)
+ self._search_engine.index_mail(moved_mail)
+ defer.returnValue(moved_mail)
+
def __getattr__(self, name):
"""
Acts like method missing. If a method of MailStore is not implemented in this class,
diff --git a/service/test/unit/adapter/mailstore/test_searchable_mailstore.py b/service/test/unit/adapter/mailstore/test_searchable_mailstore.py
index da0755c9..00695a19 100644
--- a/service/test/unit/adapter/mailstore/test_searchable_mailstore.py
+++ b/service/test/unit/adapter/mailstore/test_searchable_mailstore.py
@@ -77,6 +77,18 @@ class TestSearchableMailStore(TestCase):
verify(self.search_index).index_mail(leap_mail)
@defer.inlineCallbacks
+ def test_move_mail_delegates_to_mail_store_and_updates_index(self):
+ moved_mail = LeapMail('new id', ANY_MAILBOX)
+ when(self.delegate_mail_store).move_mail_to_mailbox('mail id', ANY_MAILBOX).thenReturn(defer.succeed(moved_mail))
+
+ result = yield self.store.move_mail_to_mailbox('mail id', ANY_MAILBOX)
+
+ verify(self.delegate_mail_store).move_mail_to_mailbox('mail id', ANY_MAILBOX)
+ verify(self.search_index).remove_from_index('mail id')
+ verify(self.search_index).index_mail(moved_mail)
+ self.assertEqual(moved_mail, result)
+
+ @defer.inlineCallbacks
def test_other_methods_are_delegated(self):
mail = LeapMail('mail id', ANY_MAILBOX)
when(self.delegate_mail_store).get_mail('mail id').thenReturn(defer.succeed(mail), defer.succeed(mail))