commit 8e737da3be712e7e9151194a381a108035d50a6c Author: Isis Lovecruft isis@torproject.org Date: Wed Apr 23 06:55:30 2014 +0000
Add unittests for bridgedb.parse.addr.extractEmail(). --- lib/bridgedb/test/test_parse_addr.py | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+)
diff --git a/lib/bridgedb/test/test_parse_addr.py b/lib/bridgedb/test/test_parse_addr.py index 6b22232..1e6af83 100644 --- a/lib/bridgedb/test/test_parse_addr.py +++ b/lib/bridgedb/test/test_parse_addr.py @@ -79,6 +79,49 @@ class CanonicalizeEmailDomainTests(unittest.TestCase): self.assertEquals(canonical, 'example.com')
+class ExtractEmailAddressTests(unittest.TestCase): + """Unittests for :func:`bridgedb.parse.addr.extractEmailAddress`.""" + + def test_23(self): + """The email address int(23) should raise a BadEmail error.""" + self.assertRaises(addr.BadEmail, + addr.extractEmailAddress, + int(23)) + + def test_lessThanChars(self): + """The email address 'Alice alice@riseup.net' should return + ('alice', 'riseup.net'). + """ + local, domain = addr.extractEmailAddress('Alice alice@riseup.net') + self.assertEqual(local, 'alice') + self.assertEqual(domain, 'riseup.net') + + def test_extraLessThanChars(self): + """The email address 'Mallory <mallory@riseup.net' should return + ('lory', 'riseup.net') + """ + local, domain = addr.extractEmailAddress('Mallory <mallory@riseup.net') + self.assertEqual(local, 'lory') + self.assertEqual(domain, 'riseup.net') + + def test_extraLessAndGreaterThanChars(self): + """The email address 'Mallory <mal><>>lory@riseup.net>' should raise a + BadEmail error. + """ + self.assertRaises(addr.BadEmail, + addr.extractEmailAddress, + 'Mallory <mal><>>lory@riseup.net>') + + def test_extraAppendedEmailAddress(self): + """The email address 'Mallory mallory@riseup.netmallory@gmail.com' + should use the last address. + """ + local, domain = addr.extractEmailAddress( + 'Mallory mallory@riseup.netmallory@gmail.com') + self.assertEqual(local, 'mallory') + self.assertEqual(domain, 'gmail.com') + + class ParseAddrIsIPAddressTests(unittest.TestCase): """Unittests for :func:`bridgedb.parse.addr.isIPAddress`.
tor-commits@lists.torproject.org