summaryrefslogtreecommitdiff
path: root/src/mailman/app/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/app/tests')
-rw-r--r--src/mailman/app/tests/test_moderation.py19
-rw-r--r--src/mailman/app/tests/test_subscriptions.py13
2 files changed, 22 insertions, 10 deletions
diff --git a/src/mailman/app/tests/test_moderation.py b/src/mailman/app/tests/test_moderation.py
index 45f94f27b..bb3958cd7 100644
--- a/src/mailman/app/tests/test_moderation.py
+++ b/src/mailman/app/tests/test_moderation.py
@@ -159,22 +159,29 @@ class TestUnsubscription(unittest.TestCase):
def test_unsubscribe_defer(self):
# When unsubscriptions must be approved by the moderator, but the
# moderator defers this decision.
- anne = getUtility(IUserManager).create_address(
- 'anne@example.org', 'Anne Person')
+ user_manager = getUtility(IUserManager)
+ anne = user_manager.create_address('anne@example.org', 'Anne Person')
token, token_owner, member = self._manager.register(
anne, pre_verified=True, pre_confirmed=True, pre_approved=True)
self.assertIsNone(token)
self.assertEqual(member.address.email, 'anne@example.org')
- mod = self._user_manager.create_user('bart@example.com', 'Bart User')
- address = set_preferred(mod)
+ bart = user_manager.create_user('bart@example.com', 'Bart User')
+ address = set_preferred(bart)
self._mlist.subscribe(address, MemberRole.moderator)
# Now hold and handle an unsubscription request.
token = hold_unsubscription(self._mlist, 'anne@example.org')
handle_unsubscription(self._mlist, token, Action.defer)
items = get_queue_messages('virgin', expected_count=2)
- moderator_message = items[1]
+ # Find the moderator message.
+ for item in items:
+ if item.msg['to'] == 'test-owner@example.com':
+ break
+ else:
+ raise AssertionError('No moderator email found')
+ self.assertEqual(item.msgdata['recipients'], {'bart@example.com'})
self.assertEqual(
- moderator_message.msgdata['recipients'], {'bart@example.com'})
+ item.msg['subject'],
+ 'New unsubscription request from Test by anne@example.org')
def test_bogus_token(self):
# Try to handle an unsubscription with a bogus token.
diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py
index e72da6b01..5d49590ca 100644
--- a/src/mailman/app/tests/test_subscriptions.py
+++ b/src/mailman/app/tests/test_subscriptions.py
@@ -436,17 +436,22 @@ class TestSubscriptionWorkflow(unittest.TestCase):
self._mlist.admin_immed_notify = True
self._mlist.subscription_policy = SubscriptionPolicy.moderate
anne = self._user_manager.create_address(self._anne)
- mod = self._user_manager.create_user('bart@example.com', 'Bart User')
- address = set_preferred(mod)
+ bart = self._user_manager.create_user('bart@example.com', 'Bart User')
+ address = set_preferred(bart)
self._mlist.subscribe(address, MemberRole.moderator)
workflow = SubscriptionWorkflow(self._mlist, anne,
pre_verified=True,
pre_confirmed=True)
# Consume the entire state machine.
list(workflow)
+ # Find the moderator message.
items = get_queue_messages('virgin', expected_count=1)
- messagedata = items[0].msgdata
- self.assertEqual(messagedata['recipients'], {'bart@example.com'})
+ for item in items:
+ if item.msg['to'] == 'test-owner@example.com':
+ break
+ else:
+ raise AssertionError('No moderator email found')
+ self.assertEqual(item.msgdata['recipients'], {'bart@example.com'})
message = items[0].msg
self.assertEqual(message['From'], 'test-owner@example.com')
self.assertEqual(message['To'], 'test-owner@example.com')