diff options
Diffstat (limited to 'tests/db/utils_test.py')
-rw-r--r-- | tests/db/utils_test.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index 19caa788..08e2d8a7 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -164,6 +164,26 @@ class TestEncodeHeader(unittest.TestCase): expected = email.header.Header('=?utf-8?b?dsOkbMO8ZQ==?=') self.assertEqual(actual, expected) + def test_plain_email_addresses_are_accepted(self): + address = 'user@example.com' + actual = utils.encode_header('from', address) + expected = email.header.Header(address) + self.assertEqual(actual, expected) + + def test_email_addresses_with_realnames_are_accepted(self): + address = 'someone <user@example.com>' + actual = utils.encode_header('from', address) + expected = email.header.Header(address) + self.assertEqual(actual, expected) + + @unittest.expectedFailure + def test_email_addresses_with_empty_realnames_are_treated_like_plain(self): + address = 'user@example.com' + empty_realname = '<'+address+'>' + actual = utils.encode_header('from', empty_realname) + expected = email.header.Header(address) + self.assertEqual(str(actual), str(expected)) + def test_space_around_email_address_is_striped(self): address = ' someone <user@example.com> ' actual = utils.encode_header('from', address) @@ -191,6 +211,13 @@ class TestEncodeHeader(unittest.TestCase): expected = email.header.Header(addresses) self.assertEqual(str(actual), str(expected)) + def test_utf_8_chars_in_realnames_are_accepted(self): + address = u'Ümlaut <uemlaut@example.com>' + actual = utils.encode_header('from', address) + expected = email.header.Header( + '=?utf-8?q?=C3=9Cmlaut?= <uemlaut@example.com>') + self.assertEqual(actual, expected) + class TestDecodeHeader(unittest.TestCase): |