summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-07-14 22:55:22 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:23 +0200
commit72c7d1da2c50621fb93e18687beb089c2d2723b8 (patch)
treee3887efde0291c66cffb7318924e7fd513427326 /service
parentb53fc14234017cc9275bc319e4e4866f1ef9c142 (diff)
prepare mailbox tests, missing property functionality on mail.py only
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/services/mailboxes.py4
-rw-r--r--service/test/unit/adapter/test_mailboxes.py4
2 files changed, 6 insertions, 2 deletions
diff --git a/service/pixelated/adapter/services/mailboxes.py b/service/pixelated/adapter/services/mailboxes.py
index 4d90f0c6..d458406b 100644
--- a/service/pixelated/adapter/services/mailboxes.py
+++ b/service/pixelated/adapter/services/mailboxes.py
@@ -72,11 +72,13 @@ class Mailboxes(object):
def move_to_inbox(self, mail_id):
return self._move_to(mail_id, self.inbox)
+ @defer.inlineCallbacks
def _move_to(self, mail_id, mailbox):
+ mailbox = yield mailbox
mail = self.querier.mail(mail_id)
mail.set_mailbox(mailbox.mailbox_name)
mail.save()
- return mail
+ defer.returnValue(mail)
def mail(self, mail_id):
return self.querier.mail(mail_id)
diff --git a/service/test/unit/adapter/test_mailboxes.py b/service/test/unit/adapter/test_mailboxes.py
index 6ff3849b..081e47fb 100644
--- a/service/test/unit/adapter/test_mailboxes.py
+++ b/service/test/unit/adapter/test_mailboxes.py
@@ -18,6 +18,7 @@ import unittest
from pixelated.adapter.model.mail import PixelatedMail
from pixelated.adapter.services.mailboxes import Mailboxes
from mockito import mock, when, verify
+from twisted.internet import defer
from test.support import test_helper
from mock import MagicMock
@@ -30,12 +31,13 @@ class PixelatedMailboxesTest(unittest.TestCase):
self.account = MagicMock()
self.mailboxes = Mailboxes(self.account, self.querier, self.search_engine)
+ @defer.inlineCallbacks
def test_move_to_inbox(self):
mail = PixelatedMail.from_soledad(*test_helper.leap_mail(), soledad_querier=self.querier)
when(self.querier).mail(1).thenReturn(mail)
when(mail).save().thenReturn(None)
mail.set_mailbox('TRASH')
- recovered_mail = self.mailboxes.move_to_inbox(1)
+ recovered_mail = yield self.mailboxes.move_to_inbox(1)
self.assertEquals('INBOX', recovered_mail.mailbox_name)
verify(mail).save()