class TestConfirm(unittest.TestCase): """Test the `confirm` command.""" layer = ConfigLayer def setUp(self): self._mlist = create_list("*****@*****.**") anne = getUtility(IUserManager).create_address("*****@*****.**", "Anne Person") self._token, token_owner, member = IRegistrar(self._mlist).register(anne) self._command = Confirm() # Clear the virgin queue. get_queue_messages("virgin") def test_welcome_message(self): # A confirmation causes a welcome message to be sent to the member, if # enabled by the mailing list. status = self._command.process(self._mlist, Message(), {}, (self._token,), Results()) self.assertEqual(status, ContinueProcessing.yes) # There should be one messages in the queue; the welcome message. messages = get_queue_messages("virgin") self.assertEqual(len(messages), 1) # Grab the welcome message. welcome = messages[0].msg self.assertEqual(welcome["subject"], 'Welcome to the "Test" mailing list') self.assertEqual(welcome["to"], "Anne Person <*****@*****.**>") def test_no_welcome_message(self): # When configured not to send a welcome message, none is sent. self._mlist.send_welcome_message = False status = self._command.process(self._mlist, Message(), {}, (self._token,), Results()) self.assertEqual(status, ContinueProcessing.yes) # There will be no messages in the queue. messages = get_queue_messages("virgin") self.assertEqual(len(messages), 0)
def setUp(self): self._mlist = create_list('*****@*****.**') self._token = getUtility(IRegistrar).register(self._mlist, '*****@*****.**', 'Anne Person') self._command = Confirm() # Clear the virgin queue. get_queue_messages('virgin')
def setUp(self): self._mlist = create_list('*****@*****.**') anne = getUtility(IUserManager).create_address('*****@*****.**', 'Anne Person') self._token, token_owner, member = IRegistrar( self._mlist).register(anne) self._command = Confirm() # Clear the virgin queue. get_queue_messages('virgin')
def setUp(self): self._mlist = create_list("*****@*****.**") anne = getUtility(IUserManager).create_address("*****@*****.**", "Anne Person") self._token, token_owner, member = IRegistrar(self._mlist).register(anne) self._command = Confirm() # Clear the virgin queue. get_queue_messages("virgin")
def setUp(self): self._mlist = create_list('*****@*****.**') self._token = getUtility(IRegistrar).register( self._mlist, '*****@*****.**', 'Anne Person') self._command = Confirm() # Clear the virgin queue. get_queue_messages('virgin')
class TestConfirmJoin(unittest.TestCase): """Test the `confirm` command when joining a mailing list.""" layer = ConfigLayer def setUp(self): self._mlist = create_list('*****@*****.**') anne = getUtility(IUserManager).create_address('*****@*****.**', 'Anne Person') self._token, token_owner, member = ISubscriptionManager( self._mlist).register(anne) self._command = Confirm() # Clear the virgin queue. get_queue_messages('virgin') def test_welcome_message(self): # A confirmation causes a welcome message to be sent to the member, if # enabled by the mailing list. status = self._command.process(self._mlist, Message(), {}, (self._token, ), Results()) self.assertEqual(status, ContinueProcessing.no) # There should be one messages in the queue; the welcome message. items = get_queue_messages('virgin', expected_count=1) # Grab the welcome message. welcome = items[0].msg self.assertEqual(welcome['subject'], 'Welcome to the "Test" mailing list') self.assertEqual(welcome['to'], 'Anne Person <*****@*****.**>') def test_no_welcome_message(self): # When configured not to send a welcome message, none is sent. self._mlist.send_welcome_message = False status = self._command.process(self._mlist, Message(), {}, (self._token, ), Results()) self.assertEqual(status, ContinueProcessing.no) # There will be no messages in the queue. get_queue_messages('virgin', expected_count=0) def test_confim_token_twice(self): # Don't try to confirm the same token twice. # We test this by passing a result that already confirms the same # token and it doesn't try to look at the database. result = Results() result.confirms = self._token status = self._command.process(self._mlist, Message(), {}, (self._token, ), result) self.assertEqual(status, ContinueProcessing.no)
def test_confirm_leave(self): msg = mfs("""\ From: Anne Person <*****@*****.**> To: test-confirm+{token}@example.com Subject: Re: confirm {token} """.format(token=self._token)) Confirm().process(self._mlist, msg, {}, (self._token, ), Results()) # Anne is no longer a member of the mailing list. member = self._mlist.members.get_member('*****@*****.**') self.assertIsNone(member)
class TestConfirm(unittest.TestCase): """Test the `confirm` command.""" layer = ConfigLayer def setUp(self): self._mlist = create_list('*****@*****.**') self._token = getUtility(IRegistrar).register(self._mlist, '*****@*****.**', 'Anne Person') self._command = Confirm() # Clear the virgin queue. get_queue_messages('virgin') def tearDown(self): reset_the_world() def test_welcome_message(self): # A confirmation causes a welcome message to be sent to the member, if # enabled by the mailing list. status = self._command.process(self._mlist, Message(), {}, (self._token, ), Results()) self.assertEqual(status, ContinueProcessing.yes) # There should be one messages in the queue; the welcome message. messages = get_queue_messages('virgin') self.assertEqual(len(messages), 1) # Grab the welcome message. welcome = messages[0].msg self.assertEqual(welcome['subject'], 'Welcome to the "Test" mailing list') self.assertEqual(welcome['to'], 'Anne Person <*****@*****.**>') def test_no_welcome_message(self): # When configured not to send a welcome message, none is sent. self._mlist.send_welcome_message = False status = self._command.process(self._mlist, Message(), {}, (self._token, ), Results()) self.assertEqual(status, ContinueProcessing.yes) # There will be no messages in the queue. messages = get_queue_messages('virgin') self.assertEqual(len(messages), 0)
class TestConfirm(unittest.TestCase): """Test the `confirm` command.""" layer = ConfigLayer def setUp(self): self._mlist = create_list('*****@*****.**') self._token = getUtility(IRegistrar).register( self._mlist, '*****@*****.**', 'Anne Person') self._command = Confirm() # Clear the virgin queue. get_queue_messages('virgin') def tearDown(self): reset_the_world() def test_welcome_message(self): # A confirmation causes a welcome message to be sent to the member, if # enabled by the mailing list. status = self._command.process( self._mlist, Message(), {}, (self._token,), Results()) self.assertEqual(status, ContinueProcessing.yes) # There should be one messages in the queue; the welcome message. messages = get_queue_messages('virgin') self.assertEqual(len(messages), 1) # Grab the welcome message. welcome = messages[0].msg self.assertEqual(welcome['subject'], 'Welcome to the "Test" mailing list') self.assertEqual(welcome['to'], 'Anne Person <*****@*****.**>') def test_no_welcome_message(self): # When configured not to send a welcome message, none is sent. self._mlist.send_welcome_message = False status = self._command.process( self._mlist, Message(), {}, (self._token,), Results()) self.assertEqual(status, ContinueProcessing.yes) # There will be no messages in the queue. messages = get_queue_messages('virgin') self.assertEqual(len(messages), 0)
def test_confirm_leave_moderate(self): msg = mfs("""\ From: Anne Person <*****@*****.**> To: test-confirm+{token}@example.com Subject: Re: confirm {token} """.format(token=self._token)) self._mlist.unsubscription_policy = ( SubscriptionPolicy.confirm_then_moderate) # Clear any previously queued confirmation messages. get_queue_messages('virgin') Confirm().process(self._mlist, msg, {}, (self._token, ), Results()) # Anne is still a member of the mailing list. member = self._mlist.members.get_member('*****@*****.**') self.assertIsNotNone(member) # There should be a notice to the list owners item = get_queue_messages('virgin', expected_count=1)[0] self.assertEqual(item.msg['to'], '*****@*****.**')
def setUp(self): self._mlist = create_list("*****@*****.**") self._token = getUtility(IRegistrar).register(self._mlist, "*****@*****.**", "Anne Person") self._command = Confirm() # Clear the virgin queue. get_queue_messages("virgin")