diff options
| author | Barry Warsaw | 2015-04-13 10:46:37 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2015-04-13 10:46:37 -0400 |
| commit | 9806f9c751f85b6ad6e9dea58d9e3dde36c7f2bc (patch) | |
| tree | 86ab2380dbd62e98af7e532c203b3cef16d9e441 /src/mailman/app/tests | |
| parent | f7bfdc4f04f8a8c709695cb37a4cdfa08e670a5a (diff) | |
| download | mailman-9806f9c751f85b6ad6e9dea58d9e3dde36c7f2bc.tar.gz mailman-9806f9c751f85b6ad6e9dea58d9e3dde36c7f2bc.tar.zst mailman-9806f9c751f85b6ad6e9dea58d9e3dde36c7f2bc.zip | |
Diffstat (limited to 'src/mailman/app/tests')
| -rw-r--r-- | src/mailman/app/tests/test_subscriptions.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py index 836e7f7b7..61d341d6d 100644 --- a/src/mailman/app/tests/test_subscriptions.py +++ b/src/mailman/app/tests/test_subscriptions.py @@ -85,8 +85,8 @@ class TestSubscriptionWorkflow(unittest.TestCase): def test_user_or_address_required(self): # The `subscriber` attribute must be a user or address. - self.assertRaises( - AssertionError, SubscriptionWorkflow, self._mlist, 'not a user') + workflow = SubscriptionWorkflow(self._mlist) + self.assertRaises(AssertionError, list, workflow) def test_sanity_checks_address(self): # Ensure that the sanity check phase, when given an IAddress, ends up @@ -325,8 +325,34 @@ class TestSubscriptionWorkflow(unittest.TestCase): member = self._mlist.regular_members.get_member(self._anne) self.assertEqual(member.address, anne) + def test_moderator_approves(self): + # The workflow runs until moderator approval is required, at which + # point the workflow is saved. Once the moderator approves, the + # workflow resumes and the user is subscribed. + self._mlist.subscription_policy = SubscriptionPolicy.moderate + anne = self._user_manager.create_address(self._anne) + workflow = SubscriptionWorkflow(self._mlist, anne, + pre_verified=True, + pre_confirmed=True) + # Consume the entire state machine. + list(workflow) + # The user is not currently subscribed to the mailing list. + member = self._mlist.regular_members.get_member(self._anne) + self.assertIsNone(member) + # Create a new workflow with the previous workflow's save token, and + # restore its state. This models an approved subscription and should + # result in the user getting subscribed. + approved_workflow = SubscriptionWorkflow(self._mlist) + approved_workflow.token = workflow.token + approved_workflow.restore() + list(approved_workflow) + # Now the user is subscribed to the mailing list. + member = self._mlist.regular_members.get_member(self._anne) + self.assertEqual(member.address, anne) + # XXX + @unittest.expectedFailure def test_preverified_address_joins_open_list(self): # The mailing list has an open subscription policy, so the subscriber # becomes a member with no human intervention. @@ -346,6 +372,7 @@ class TestSubscriptionWorkflow(unittest.TestCase): self.assertIsNotNone(anne.user) self.assertIsNotNone(self._mlist.subscribers.get_member(self._anne)) + @unittest.expectedFailure def test_verified_address_joins_moderated_list(self): # The mailing list is moderated but the subscriber is not a verified # address and the subscription request is not pre-verified. |
