2 # -*- coding: utf-8 -*-
4 from base_test import DakTestCase
8 from daklib.textutils import fix_maintainer
9 from daklib.dak_exceptions import ParseMaintError
11 class FixMaintainerTestCase(DakTestCase):
12 def assertValid(self, input, a, b, c, d):
13 a_, b_, c_, d_ = fix_maintainer(input)
15 self.assertEqual(a, a_)
16 self.assertEqual(b, b_)
17 self.assertEqual(c, c_)
18 self.assertEqual(d, d_)
20 def assertNotValid(self, input):
21 self.assertRaises(ParseMaintError, lambda: fix_maintainer(input))
23 def testUTF8Maintainer(self):
24 # Check Valid UTF-8 maintainer field
26 "Noèl Köthe <noel@debian.org>",
27 "Noèl Köthe <noel@debian.org>",
28 "=?utf-8?b?Tm/DqGwgS8O2dGhl?= <noel@debian.org>",
34 # Check valid ASCII maintainer field
36 "James Troup <james@nocrew.org>",
37 "James Troup <james@nocrew.org>",
38 "James Troup <james@nocrew.org>",
44 # Check "Debian vs RFC822" fixup of names with '.' or ',' in them
46 "James J. Troup <james@nocrew.org>",
47 "james@nocrew.org (James J. Troup)",
48 "james@nocrew.org (James J. Troup)",
55 "James J, Troup <james@nocrew.org>",
56 "james@nocrew.org (James J, Troup)",
57 "james@nocrew.org (James J, Troup)",
62 def testJustEmail(self):
63 # Check just-email form
66 " <james@nocrew.org>",
67 " <james@nocrew.org>",
72 def testBracketedEmail(self):
73 # Check bracketed just-email form
76 " <james@nocrew.org>",
77 " <james@nocrew.org>",
83 # Check Krazy quoted-string local part email address
85 "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>",
86 "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>",
87 "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>",
89 "\"Cris van Pelt\"@tribe.eu.org",
92 def testEmptyString(self):
94 self.assertValid("", "", "", "", "")
96 def testMissingEmailAddress(self):
97 # Check for missing email address
98 self.assertNotValid("James Troup")
100 def testInvalidEmail(self):
101 # Check for invalid email address
102 self.assertNotValid("James Troup <james@nocrew.org")
104 if __name__ == '__main__':