summaryrefslogtreecommitdiff
path: root/tests/commands
diff options
context:
space:
mode:
authorJulian Mehne <julian.mehne@posteo.de>2018-02-15 00:32:28 +0100
committerJulian Mehne <julian.mehne@posteo.de>2018-02-15 01:00:23 +0100
commit4a99e47f189f5806c035acf982ed46598ea9ad61 (patch)
tree60b852db5bd9217d602905d79dfd5a68837b2d66 /tests/commands
parent7a37daee30c271e2aca7546bee910d419e4c2998 (diff)
Add test: template not decoded properly.
Diffstat (limited to 'tests/commands')
-rw-r--r--tests/commands/global_test.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/commands/global_test.py b/tests/commands/global_test.py
index 9489c909..96cba2d7 100644
--- a/tests/commands/global_test.py
+++ b/tests/commands/global_test.py
@@ -18,6 +18,7 @@
from __future__ import absolute_import
import os
+import tempfile
from twisted.trial import unittest
from twisted.internet.defer import inlineCallbacks
@@ -118,6 +119,33 @@ class TestComposeCommand(unittest.TestCase):
self.assertFalse(envelope.sign)
self.assertIs(envelope.sign_key, None)
+ @inlineCallbacks
+ def test_decode_template_on_loading(self):
+ subject = u'This is a täßϑ subject.'
+ to = u'recipient@mail.com'
+ _from = u'foo.bar@mail.fr'
+ body = u'Body\n地初店会継思識棋御招告外児山望掲領環。\n€mail body €nd.'
+ with tempfile.NamedTemporaryFile('wb', delete=False) as f:
+ txt = u'Subject: {}\nTo: {}\nFrom: {}\n{}'.format(subject, to,
+ _from, body)
+ f.write(txt.encode('utf-8'))
+ self.addCleanup(os.unlink, f.name)
+
+ cmd = g_commands.ComposeCommand(template=f.name)
+
+ # Crutch to exit the giant `apply` method early.
+ with mock.patch('alot.commands.globals.settings.get_account_by_address',
+ mock.Mock(side_effect=Stop)):
+ try:
+ yield cmd.apply(mock.Mock())
+ except Stop:
+ pass
+
+ self.assertEqual({'To': [to],
+ 'From': [_from],
+ 'Subject': [subject]}, cmd.envelope.headers)
+ self.assertEqual(body, cmd.envelope.body)
+
class TestExternalCommand(unittest.TestCase):