Esempio n. 1
0
 def testFixMaintainerRaises(self):
     """lp.archiveuploader.utils.fix_maintainer should raise on incorrect
        values
     """
     from lp.archiveuploader.utils import fix_maintainer, ParseMaintError
     cases = (
         "James Troup",
         "James Troup <james>",
         "James Troup <*****@*****.**")
     for case in cases:
         try:
             fix_maintainer(case)
             self.assertNotReached()
         except ParseMaintError:
             pass
Esempio n. 2
0
    def testFixMaintainerOkay(self):
        """lp.archiveuploader.utils.fix_maintainer should parse correct values
        """
        from lp.archiveuploader.utils import fix_maintainer
        cases = (
            ("No\xc3\xa8l K\xc3\xb6the <*****@*****.**>",
             "No\xc3\xa8l K\xc3\xb6the <*****@*****.**>",
             "=?utf-8?b?Tm/DqGwgS8O2dGhl?= <*****@*****.**>",
             "No\xc3\xa8l K\xc3\xb6the",
             "*****@*****.**"),

            ("No\xe8l K\xf6the <*****@*****.**>",
             "No\xc3\xa8l K\xc3\xb6the <*****@*****.**>",
             "=?iso-8859-1?q?No=E8l_K=F6the?= <*****@*****.**>",
             "No\xc3\xa8l K\xc3\xb6the",
             "*****@*****.**"),

            ("James Troup <*****@*****.**>",
             "James Troup <*****@*****.**>",
             "James Troup <*****@*****.**>",
             "James Troup",
             "*****@*****.**"),

            ("James J. Troup <*****@*****.**>",
             "[email protected] (James J. Troup)",
             "[email protected] (James J. Troup)",
             "James J. Troup",
             "*****@*****.**"),

            ("James J, Troup <*****@*****.**>",
             "[email protected] (James J, Troup)",
             "[email protected] (James J, Troup)",
             "James J, Troup",
             "*****@*****.**"),

            ("*****@*****.**",
             " <*****@*****.**>",
             " <*****@*****.**>",
             "",
             "*****@*****.**"),

            ("<*****@*****.**>",
             " <*****@*****.**>",
             " <*****@*****.**>",
             "",
             "*****@*****.**"),

            ("Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>",
             "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>",
             "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>",
             "Cris van Pelt",
             "\"Cris van Pelt\"@tribe.eu.org"),

            ("Zak B. Elep <*****@*****.**>",
             "[email protected] (Zak B. Elep)",
             "[email protected] (Zak B. Elep)",
             "Zak B. Elep",
             "*****@*****.**"),

            ("[email protected] (Zak B. Elep)",
             " <[email protected] (Zak B. Elep)>",
             " <[email protected] (Zak B. Elep)>",
             "",
             "[email protected] (Zak B. Elep)"),
             )

        for case in cases:
            (a, b, c, d) = fix_maintainer(case[0])
            self.assertEquals(case[1], a)
            self.assertEquals(case[2], b)
            self.assertEquals(case[3], c)
            self.assertEquals(case[4], d)