class TestCreate(unittest.TestCase): """Test `bin/mailman create`.""" layer = ConfigLayer def setUp(self): self.command = Create() self.command.parser = FakeParser() self.args = FakeArgs() def test_cannot_create_duplicate_list(self): # Cannot create a mailing list if it already exists. create_list('*****@*****.**') self.args.listname = ['*****@*****.**'] try: self.command.process(self.args) except SystemExit: pass self.assertEqual(self.command.parser.message, 'List already exists: [email protected]') def test_invalid_posting_address(self): # Cannot create a mailing list with an invalid posting address. self.args.listname = ['foo'] try: self.command.process(self.args) except SystemExit: pass self.assertEqual(self.command.parser.message, 'Illegal list name: foo') def test_invalid_owner_addresses(self): # Cannot create a list with invalid owner addresses. LP: #778687 self.args.listname = ['*****@*****.**'] self.args.domain = True self.args.owners = ['main=True'] try: self.command.process(self.args) except SystemExit: pass self.assertEqual(self.command.parser.message, 'Illegal owner addresses: main=True')
class TestCreate(unittest.TestCase): layer = ConfigLayer def setUp(self): self.command = Create() self.command.parser = FakeParser() self.args = FakeArgs() def test_cannot_create_duplicate_list(self): # Cannot create a mailing list if it already exists. create_list('*****@*****.**') self.args.listname = ['*****@*****.**'] try: self.command.process(self.args) except SystemExit: pass self.assertEqual(self.command.parser.message, 'List already exists: [email protected]') def test_invalid_posting_address(self): # Cannot create a mailing list with an invalid posting address. self.args.listname = ['foo'] try: self.command.process(self.args) except SystemExit: pass self.assertEqual(self.command.parser.message, 'Illegal list name: foo') def test_invalid_owner_addresses(self): # Cannot create a list with invalid owner addresses. LP: #778687 self.args.listname = ['*****@*****.**'] self.args.domain = True self.args.owners = ['main=True'] try: self.command.process(self.args) except SystemExit: pass self.assertEqual(self.command.parser.message, 'Illegal owner addresses: main=True')
def setUp(self): self.command = Create() self.command.parser = FakeParser() self.args = FakeArgs()
class TestCreate(unittest.TestCase): layer = ConfigLayer def setUp(self): self.command = Create() self.command.parser = FakeParser() self.args = FakeArgs() def test_cannot_create_duplicate_list(self): # Cannot create a mailing list if it already exists. create_list('*****@*****.**') self.args.listname = ['*****@*****.**'] with suppress(SystemExit): self.command.process(self.args) self.assertEqual(self.command.parser.message, 'List already exists: [email protected]') def test_invalid_posting_address(self): # Cannot create a mailing list with an invalid posting address. self.args.listname = ['foo'] with suppress(SystemExit): self.command.process(self.args) self.assertEqual(self.command.parser.message, 'Illegal list name: foo') def test_invalid_owner_addresses(self): # Cannot create a list with invalid owner addresses. LP: #778687 self.args.listname = ['*****@*****.**'] self.args.owners = ['main=True'] with suppress(SystemExit): self.command.process(self.args) self.assertEqual(self.command.parser.message, 'Illegal owner addresses: main=True') def test_without_domain_option(self): # The domain will be created if no domain options are specified. parser = ArgumentParser() self.command.add(FakeParser(), parser) args = parser.parse_args('*****@*****.**'.split()) self.assertTrue(args.domain) def test_with_domain_option(self): # The domain will be created if -d is given explicitly. parser = ArgumentParser() self.command.add(FakeParser(), parser) args = parser.parse_args('-d [email protected]'.split()) self.assertTrue(args.domain) def test_with_nodomain_option(self): # The domain will not be created if --no-domain is given. parser = ArgumentParser() self.command.add(FakeParser(), parser) args = parser.parse_args('-D [email protected]'.split()) self.assertFalse(args.domain) def test_error_when_not_creating_domain(self): self.args.domain = False self.args.listname = ['*****@*****.**'] with self.assertRaises(SystemExit) as cm: self.command.process(self.args) self.assertEqual(cm.exception.code, 1) self.assertEqual(self.command.parser.message, 'Undefined domain: example.org')