summaryrefslogtreecommitdiff
path: root/service/test/unit/maintenance
diff options
context:
space:
mode:
Diffstat (limited to 'service/test/unit/maintenance')
-rw-r--r--service/test/unit/maintenance/test_commands.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/service/test/unit/maintenance/test_commands.py b/service/test/unit/maintenance/test_commands.py
index 52fe6ca2..a0fc58d6 100644
--- a/service/test/unit/maintenance/test_commands.py
+++ b/service/test/unit/maintenance/test_commands.py
@@ -80,8 +80,8 @@ class TestCommands(unittest.TestCase):
def test_load_mails_adds_mails(self):
# given
mail_root = pkg_resources.resource_filename('test.unit.fixtures', 'mailset')
- firstMailDeferred = defer.succeed(None)
- secondMailDeferred = defer.succeed(None)
+ firstMailDeferred = defer.succeed(MagicMock())
+ secondMailDeferred = defer.succeed(MagicMock())
self.mail_store.add_mail.side_effect = [firstMailDeferred, secondMailDeferred]
self.mail_store.add_mailbox.return_value = defer.succeed(None)
@@ -104,6 +104,26 @@ class TestCommands(unittest.TestCase):
return d
+ def test_load_mails_supports_mbox(self):
+ # given
+ mbox_file = pkg_resources.resource_filename('test.unit.fixtures', 'mbox')
+
+ d = load_mails(self.args, [mbox_file])
+
+ # then
+ def assert_mails_added(_):
+ self.assertTrue(self.mail_store.add_mail.called)
+ self.mail_store.add_mail.assert_any_call('INBOX', self._mail_content(mbox_file))
+
+ def error_callack(err):
+ print err
+ self.assertTrue(False)
+
+ d.addCallback(assert_mails_added)
+ d.addErrback(error_callack)
+
+ return d
+
def _mail_content(self, mail_file):
with open(mail_file, 'r') as fp:
m = email.message_from_file(fp)