summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/listeners/mailbox_indexer_listener.py2
-rw-r--r--service/test/integration/test_incoming_mail.py51
2 files changed, 53 insertions, 0 deletions
diff --git a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py
index 8e7eca1a..77a78f0e 100644
--- a/service/pixelated/adapter/listeners/mailbox_indexer_listener.py
+++ b/service/pixelated/adapter/listeners/mailbox_indexer_listener.py
@@ -30,6 +30,8 @@ class MailboxIndexerListener(object):
mbx = yield account.getMailbox(mailbox_name)
mbx.addListener(listener)
+ defer.returnValue(listener)
+
def __init__(self, mailbox_name, mail_store):
self.mailbox_name = mailbox_name
self.mail_store = mail_store
diff --git a/service/test/integration/test_incoming_mail.py b/service/test/integration/test_incoming_mail.py
new file mode 100644
index 00000000..1f3911ff
--- /dev/null
+++ b/service/test/integration/test_incoming_mail.py
@@ -0,0 +1,51 @@
+#
+# Copyright (c) 2014 ThoughtWorks, Inc.
+#
+# Pixelated is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Pixelated is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+from pixelated.adapter.listeners.mailbox_indexer_listener import MailboxIndexerListener
+from test.support.integration import SoledadTestBase, MailBuilder
+from twisted.internet import defer, reactor
+
+IGNORED = None
+
+
+class IncomingMailTest(SoledadTestBase):
+
+ @defer.inlineCallbacks
+ def test_message_collection(self):
+ # given
+ MailboxIndexerListener.SEARCH_ENGINE = self.search_engine
+
+ yield MailboxIndexerListener.listen(self.account, 'INBOX', self.mail_store)
+
+ mbx = yield self.account.getMailbox('INBOX')
+
+ input_mail = MailBuilder().build_input_mail()
+
+ yield mbx.addMessage(input_mail.raw, [])
+
+ yield self.wait_in_reactor()
+
+ mails, mail_count = self.search_engine.search('in:all')
+ self.assertEqual(1, mail_count)
+ self.assertEqual(1, len(mails))
+
+ def wait_in_reactor(self):
+ d = defer.Deferred()
+
+ def done_waiting():
+ d.callback(None)
+
+ reactor.callLater(1.0, done_waiting)
+ return d