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'*****@*****.**')
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'*****@*****.**')
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'*****@*****.**')
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'*****@*****.**')
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'*****@*****.**')
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'*****@*****.**')
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
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