예제 #1
0
 def test_logging(self):
     # Test that nothing gets logged when all imports are fine.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertEqual(self.logger.getLogBuffer(), '')
예제 #2
0
 def test_logging(self):
     # Test that nothing gets logged when all imports are fine.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertEqual(self.logger.getLogBuffer(), '')
예제 #3
0
 def test_import_from_file(self):
     # Test importing addresses from a file.
     importer = Importer('aardvarks')
     self.writeFile(
         'Anne Person <*****@*****.**>',
         '[email protected] (Bart Q. Person)',
         '*****@*****.**',
         '[email protected] (Dave Person)',
         'Elly Q. Person <*****@*****.**',
         )
     importer.importFromFile(self.filename)
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**')
예제 #4
0
 def test_import_from_file(self):
     # Test importing addresses from a file.
     importer = Importer('aardvarks')
     self.writeFile(
         'Anne Person <*****@*****.**>',
         '[email protected] (Bart Q. Person)',
         '*****@*****.**',
         '[email protected] (Dave Person)',
         'Elly Q. Person <*****@*****.**',
     )
     importer.importFromFile(self.filename)
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**', u'*****@*****.**',
                          u'*****@*****.**')
예제 #5
0
 def test_simple_import_membership(self):
     # Test the import of a list/team membership to a restricted, private
     # team.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**')
예제 #6
0
 def test_extended_import_membership(self):
     # Test the import of a list/team membership, where all email
     # addresses being imported actually exist in Launchpad.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '[email protected] (Anne Person)',
         'Bart Q. Person <*****@*****.**>',
         '*****@*****.**',
         '*****@*****.**',
         '[email protected] (Elly Q. Person)',
         ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**')
예제 #7
0
 def test_extended_import_membership(self):
     # Test the import of a list/team membership, where all email
     # addresses being imported actually exist in Launchpad.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '[email protected] (Anne Person)',
         'Bart Q. Person <*****@*****.**>',
         '*****@*****.**',
         '*****@*****.**',
         '[email protected] (Elly Q. Person)',
     ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**')
예제 #8
0
 def test_simple_import_membership(self):
     # Test the import of a list/team membership to a restricted, private
     # team.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**')
예제 #9
0
 def test_import_existing_with_nonascii_name(self):
     # Make sure that a person with a non-ascii name, who's already a
     # member of the list, gets a proper log message.
     self.anne.displayname = u'\u1ea2nn\u1ebf P\u1ec5rs\u1ed1n'
     importer = Importer('aardvarks', self.logger)
     self.anne.join(self.team)
     self.mailing_list.subscribe(self.anne)
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertEqual(
         self.logger.getLogBuffer(), 'ERROR \xe1\xba\xa2nn\xe1\xba\xbf '
         'P\xe1\xbb\x85rs\xe1\xbb\x91n is already subscribed '
         'to list Aardvarks\n'
         'INFO [email protected] (anne) joined and subscribed\n'
         'INFO [email protected] (bart) joined and subscribed\n')
예제 #10
0
 def test_logging_extended(self):
     # Test that nothing gets logged when all imports are fine.
     importer = Importer('aardvarks', self.logger)
     importer.importAddresses((
         '[email protected] (Anne Person)',
         'Bart Q. Person <*****@*****.**>',
         '*****@*****.**',
         '*****@*****.**',
         '[email protected] (Elly Q. Person)',
         ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'INFO [email protected] (anne) joined and subscribed\n'
         'INFO [email protected] (bart) joined and subscribed\n'
         'INFO [email protected] (cris) joined and subscribed\n'
         'INFO [email protected] (dave) joined and subscribed\n'
         'INFO [email protected] (elly) joined and subscribed\n')
예제 #11
0
 def test_logging_extended(self):
     # Test that nothing gets logged when all imports are fine.
     importer = Importer('aardvarks', self.logger)
     importer.importAddresses((
         '[email protected] (Anne Person)',
         'Bart Q. Person <*****@*****.**>',
         '*****@*****.**',
         '*****@*****.**',
         '[email protected] (Elly Q. Person)',
     ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'INFO [email protected] (anne) joined and subscribed\n'
         'INFO [email protected] (bart) joined and subscribed\n'
         'INFO [email protected] (cris) joined and subscribed\n'
         'INFO [email protected] (dave) joined and subscribed\n'
         'INFO [email protected] (elly) joined and subscribed\n')
예제 #12
0
 def test_already_joined(self):
     # Test import when a user is already joined to the team, but
     # not subscribed to the mailing list.
     importer = Importer('aardvarks')
     self.anne.join(self.team)
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**')
예제 #13
0
 def test_import_from_file_with_invalid_emails(self):
     # Test importing addresses from a file with invalid emails.
     importer = Importer('aardvarks')
     # Give Anne a new invalid email address.
     factory.makeEmail('*****@*****.**', self.anne,
                       email_status=EmailAddressStatus.NEW)
     self.writeFile(
         'Anne Person <*****@*****.**>',
         '[email protected] (Bart Q. Person)',
         '*****@*****.**',
         '[email protected] (Dave Person)',
         'Elly Q. Person <*****@*****.**',
         )
     importer.importFromFile(self.filename)
     self.assertPeople(u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**')
예제 #14
0
 def test_already_joined(self):
     # Test import when a user is already joined to the team, but
     # not subscribed to the mailing list.
     importer = Importer('aardvarks')
     self.anne.join(self.team)
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**')
예제 #15
0
 def test_import_existing_with_nonascii_name(self):
     # Make sure that a person with a non-ascii name, who's already a
     # member of the list, gets a proper log message.
     self.anne.displayname = u'\u1ea2nn\u1ebf P\u1ec5rs\u1ed1n'
     importer = Importer('aardvarks', self.logger)
     self.anne.join(self.team)
     self.mailing_list.subscribe(self.anne)
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'ERROR \xe1\xba\xa2nn\xe1\xba\xbf '
         'P\xe1\xbb\x85rs\xe1\xbb\x91n is already subscribed '
         'to list Aardvarks\n'
         'INFO [email protected] (anne) joined and subscribed\n'
         'INFO [email protected] (bart) joined and subscribed\n')
예제 #16
0
 def test_import_from_file_with_invalid_emails(self):
     # Test importing addresses from a file with invalid emails.
     importer = Importer('aardvarks')
     # Give Anne a new invalid email address.
     factory.makeEmail('*****@*****.**',
                       self.anne,
                       email_status=EmailAddressStatus.NEW)
     self.writeFile(
         'Anne Person <*****@*****.**>',
         '[email protected] (Bart Q. Person)',
         '*****@*****.**',
         '[email protected] (Dave Person)',
         'Elly Q. Person <*****@*****.**',
     )
     importer.importFromFile(self.filename)
     self.assertPeople(u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**', u'*****@*****.**',
                          u'*****@*****.**')
예제 #17
0
 def test_import_with_non_persons(self):
     # Test the import of a list/team membership where not all the
     # email addresses are associated with registered people.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         # Non-persons.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**')
예제 #18
0
 def test_import_with_invalid_emails(self):
     # Test the import of a list/team membership where all the
     # emails are associated with valid people, but not all of the
     # email addresses are validated.
     importer = Importer('aardvarks')
     # Give Anne a new invalid email address.
     factory.makeEmail('*****@*****.**', self.anne,
                       email_status=EmailAddressStatus.NEW)
     importer.importAddresses((
         # Import Anne's alternative address.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertPeople(u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**')
예제 #19
0
 def test_logging_with_invalid_emails(self):
     # Test that invalid emails that were not imported are logged.
     importer = Importer('aardvarks', self.logger)
     # Give Anne a new invalid email address.
     factory.makeEmail('*****@*****.**', self.anne,
                       email_status=EmailAddressStatus.NEW)
     importer.importAddresses((
         # Import Anne's alternative address.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'ERROR No valid email for address: [email protected]\n'
         'INFO [email protected] (bart) joined and subscribed\n'
         'INFO [email protected] (cris) joined and subscribed\n'
         'INFO [email protected] (dave) joined and subscribed\n'
         'INFO [email protected] (elly) joined and subscribed\n')
예제 #20
0
 def test_import_with_non_persons(self):
     # Test the import of a list/team membership where not all the
     # email addresses are associated with registered people.
     importer = Importer('aardvarks')
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         # Non-persons.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**')
예제 #21
0
 def test_import_with_invalid_emails(self):
     # Test the import of a list/team membership where all the
     # emails are associated with valid people, but not all of the
     # email addresses are validated.
     importer = Importer('aardvarks')
     # Give Anne a new invalid email address.
     factory.makeEmail('*****@*****.**',
                       self.anne,
                       email_status=EmailAddressStatus.NEW)
     importer.importAddresses((
         # Import Anne's alternative address.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertPeople(u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**')
예제 #22
0
 def test_logging_with_invalid_emails(self):
     # Test that invalid emails that were not imported are logged.
     importer = Importer('aardvarks', self.logger)
     # Give Anne a new invalid email address.
     factory.makeEmail('*****@*****.**',
                       self.anne,
                       email_status=EmailAddressStatus.NEW)
     importer.importAddresses((
         # Import Anne's alternative address.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'ERROR No valid email for address: [email protected]\n'
         'INFO [email protected] (bart) joined and subscribed\n'
         'INFO [email protected] (cris) joined and subscribed\n'
         'INFO [email protected] (dave) joined and subscribed\n'
         'INFO [email protected] (elly) joined and subscribed\n')
예제 #23
0
 def test_import_from_file_with_non_persons(self):
     # Test the import of a list/team membership from a file where
     # not all the email addresses are associated with registered
     # people.
     importer = Importer('aardvarks')
     self.writeFile(
         'Anne Person <*****@*****.**>',
         '[email protected] (Bart Q. Person)',
         '*****@*****.**',
         '[email protected] (Dave Person)',
         'Elly Q. Person <*****@*****.**',
         # Non-persons.
         '[email protected] (Fred Q. Person)',
         'Gwen Person <*****@*****.**>',
         '*****@*****.**',
         '*****@*****.**',
         )
     importer.importFromFile(self.filename)
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**', u'*****@*****.**',
         u'*****@*****.**')
예제 #24
0
 def test_import_from_file_with_non_persons(self):
     # Test the import of a list/team membership from a file where
     # not all the email addresses are associated with registered
     # people.
     importer = Importer('aardvarks')
     self.writeFile(
         'Anne Person <*****@*****.**>',
         '[email protected] (Bart Q. Person)',
         '*****@*****.**',
         '[email protected] (Dave Person)',
         'Elly Q. Person <*****@*****.**',
         # Non-persons.
         '[email protected] (Fred Q. Person)',
         'Gwen Person <*****@*****.**>',
         '*****@*****.**',
         '*****@*****.**',
     )
     importer.importFromFile(self.filename)
     self.assertPeople(u'anne', u'bart', u'cris', u'dave', u'elly')
     self.assertAddresses(u'*****@*****.**',
                          u'*****@*****.**',
                          u'*****@*****.**', u'*****@*****.**',
                          u'*****@*****.**')
예제 #25
0
    def main(self):
        """See `LaunchpadScript`."""
        team_name = None
        if len(self.args) == 0:
            self.parser.error('Missing team name')
        elif len(self.args) > 1:
            self.parser.error('Too many arguments')
        else:
            team_name = self.args[0]

        importer = Importer(team_name, self.logger)

        # Suppress sending emails based on the (absence) of the --notification
        # switch.  Notifications are disabled by default because they can
        # cause huge amounts to be sent to the team owner.
        send_email_config = """
            [immediate_mail]
            send_email: %s
            """ % self.options.notifications
        config.push('send_email_config', send_email_config)

        if self.options.filename == '-':
            # Read all the addresses from standard input, parse them
            # here, and use the direct interface to the importer.
            addresses = []
            while True:
                line = sys.stdin.readline()
                if line == '':
                    break
                addresses.append(line[:-1])
            importer.importAddresses(addresses)
        else:
            importer.importFromFile(self.options.filename)

        # All done; commit the database changes.
        self.txn.commit()
        return 0
예제 #26
0
 def test_logging_with_non_persons(self):
     # Test that non-persons that were not imported are logged.
     importer = Importer('aardvarks', self.logger)
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         # Non-persons.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
     ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'INFO [email protected] (anne) joined and subscribed\n'
         'INFO [email protected] (bart) joined and subscribed\n'
         'INFO [email protected] (cris) joined and subscribed\n'
         'INFO [email protected] (dave) joined and subscribed\n'
         'INFO [email protected] (elly) joined and subscribed\n'
         'ERROR No person for address: [email protected]\n'
         'ERROR No person for address: [email protected]\n'
         'ERROR No person for address: [email protected]\n')
예제 #27
0
 def test_logging_with_non_persons(self):
     # Test that non-persons that were not imported are logged.
     importer = Importer('aardvarks', self.logger)
     importer.importAddresses((
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         # Non-persons.
         '*****@*****.**',
         '*****@*****.**',
         '*****@*****.**',
         ))
     self.assertEqual(
         self.logger.getLogBuffer(),
         'INFO [email protected] (anne) joined and subscribed\n'
         'INFO [email protected] (bart) joined and subscribed\n'
         'INFO [email protected] (cris) joined and subscribed\n'
         'INFO [email protected] (dave) joined and subscribed\n'
         'INFO [email protected] (elly) joined and subscribed\n'
         'ERROR No person for address: [email protected]\n'
         'ERROR No person for address: [email protected]\n'
         'ERROR No person for address: [email protected]\n')
예제 #28
0
    def main(self):
        """See `LaunchpadScript`."""
        team_name = None
        if len(self.args) == 0:
            self.parser.error('Missing team name')
        elif len(self.args) > 1:
            self.parser.error('Too many arguments')
        else:
            team_name = self.args[0]

        importer = Importer(team_name, self.logger)

        # Suppress sending emails based on the (absence) of the --notification
        # switch.  Notifications are disabled by default because they can
        # cause huge amounts to be sent to the team owner.
        send_email_config = """
            [immediate_mail]
            send_email: %s
            """ % self.options.notifications
        config.push('send_email_config', send_email_config)

        if self.options.filename == '-':
            # Read all the addresses from standard input, parse them
            # here, and use the direct interface to the importer.
            addresses = []
            while True:
                line = sys.stdin.readline()
                if line == '':
                    break
                addresses.append(line[:-1])
            importer.importAddresses(addresses)
        else:
            importer.importFromFile(self.options.filename)

        # All done; commit the database changes.
        self.txn.commit()
        return 0