diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2019-05-27 19:06:26 +0100 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2019-06-02 14:44:13 +0100 |
commit | d916b5e42ffd6b5128333321d68365744ca08b1d (patch) | |
tree | dcd88f821896cde7ea70cfa06a3b2d88e7609218 /tests | |
parent | 7acf408aeddf903966c970ac0d31f95e7e956dd7 (diff) |
tests: db.utils.formataddr
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/test_utils.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/db/test_utils.py b/tests/db/test_utils.py index 6ddc8843..71671e32 100644 --- a/tests/db/test_utils.py +++ b/tests/db/test_utils.py @@ -9,6 +9,7 @@ import email import email.header import email.mime.application import email.policy +import email.utils import io import os import os.path @@ -856,3 +857,27 @@ class TestClearMyAddress(unittest.TestCase): self.assertListEqual(actual, expected) +class TestFormataddr(unittest.TestCase): + + address = u'me@example.com' + umlauts_and_comma = '"Ö, Ä" <a@b.c>' + + def test_is_inverse(self): + self.assertEqual( + utils.formataddr(email.utils.parseaddr(self.umlauts_and_comma)), + self.umlauts_and_comma + ) + + def test_address_only(self): + self.assertEqual(utils.formataddr(("", self.address)), self.address) + + def test_name_and_address_no_comma(self): + self.assertEqual( + utils.formataddr(("Me", self.address)), + "Me <me@example.com>" + ) + def test_name_and_address_with_comma(self): + self.assertEqual( + utils.formataddr(("Last, Name", self.address)), + "\"Last, Name\" <me@example.com>" + ) |