summaryrefslogtreecommitdiff
path: root/service/test/unit/maintenance
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2015-10-28 12:05:59 +0100
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-10-28 12:08:41 +0100
commit70c770635199cfa473608162ec7d31e030a11c5f (patch)
tree5bb5d9ff72a6edabf756256ca30eed0a21e180a4 /service/test/unit/maintenance
parent41b462e9b29d62dc197be6d8a633c1b9a46688cf (diff)
Add markov-generate to load-mails
- Allows to generat mails based on a sample mails - use it with: pixelated-maintenance markov-generate --seed 21 --limit 10
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)