diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2017-08-22 12:08:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 12:08:34 -0700 |
commit | 052bd44cd92d79473717806487cbbe4ca3f34bd2 (patch) | |
tree | 574428e4334275baeaba001d7f9ce6238ef1f640 /tests | |
parent | c53f2064460c0c633aee5386f01dc03716c42ecb (diff) | |
parent | f475b96685686cb1f5597ac063de950f4efb0c85 (diff) |
Merge pull request #1133 from lucc/fix/bug-1132
Fix #1132 by reverting part of fa3dd1b04567.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/helper_test.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/helper_test.py b/tests/helper_test.py index b0e799ca..62e37ed8 100644 --- a/tests/helper_test.py +++ b/tests/helper_test.py @@ -20,6 +20,7 @@ from __future__ import absolute_import import datetime +import email import errno import random import unittest @@ -379,3 +380,25 @@ class TestCallCmd(unittest.TestCase): self.assertEqual(out, u'') self.assertEqual(err, u'foobar') self.assertEqual(code, 42) + + +class TestEmailAsString(unittest.TestCase): + + def test_empty_message(self): + message = email.message.Message() + actual = helper.email_as_string(message) + expected = '\r\n' + self.assertEqual(actual, expected) + + def test_empty_message_with_unicode_header(self): + """Test if unicode header keys can be used in an email that is + converted to string with email_as_string().""" + # This is what alot.db.envelope.Envelope.construct_mail() currently + # does: It constructs a message object and then copies all headers from + # the envelope to the message object. Some header names are stored as + # unicode in the envelope. + message = email.message.Message() + message[u'X-Unicode-Header'] = 'dummy value' + actual = helper.email_as_string(message) + expected = 'X-Unicode-Header: dummy value\r\n\r\n' + self.assertEqual(actual, expected) |