diff options
| author | Barry Warsaw | 2016-10-17 09:13:32 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2016-10-17 09:13:32 -0400 |
| commit | d45af03c4f2a560d51631fdfa7c55cd1a98e722c (patch) | |
| tree | 6cc33aa452d78c38a5d38e83855c5341f0422c2a /src/mailman/app/tests/test_unsubscriptions.py | |
| parent | 82a913bbf0e8772e7c98d5eb6160fe5b9f7f6f60 (diff) | |
| download | mailman-d45af03c4f2a560d51631fdfa7c55cd1a98e722c.tar.gz mailman-d45af03c4f2a560d51631fdfa7c55cd1a98e722c.tar.zst mailman-d45af03c4f2a560d51631fdfa7c55cd1a98e722c.zip | |
Simplify the implementation.
This merges the SubscriptionManager and UnsubscriptionManager into a
single SubscriptionManager implementation that handles both register()
and unregister(). This allows us to use direct class-based adaptation
instead of the more clunky getAdapter() API. We can also eliminate the
funky _get_workflow() implementation detail.
This has a couple of side-effects. .confirm() must lookup the token in
the pendings database and pull out the pending type, dispatching to the
proper class depending on the type, or raising a LookupError if the
token is None or there is no pendable associated with the given token.
This feels like an acceptable trade-off.
However, this *also* means that IWorkflowStateManager must lose its
'name' argument in its methods. That's because we won't actually know
the name until its too late. Honestly, the name wasn't providing much
value anyway (it was always the subclass's name), so losing that seems
fine too. The complication here is that the name was a primary key in
the 'workflowstate' table, so we need to add its removal in the database
migration.
Diffstat (limited to 'src/mailman/app/tests/test_unsubscriptions.py')
| -rw-r--r-- | src/mailman/app/tests/test_unsubscriptions.py | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/mailman/app/tests/test_unsubscriptions.py b/src/mailman/app/tests/test_unsubscriptions.py index b7693f774..d8dbc18cb 100644 --- a/src/mailman/app/tests/test_unsubscriptions.py +++ b/src/mailman/app/tests/test_unsubscriptions.py @@ -184,7 +184,7 @@ class TestUnSubscriptionWorkflow(unittest.TestCase): self.assertIsNone(workflow.token) self.assertEqual(workflow.token_owner, TokenOwner.no_one) - def test_do_unsubscription_pre_approved_pre_onfirmed(self): + def test_do_unsubscription_pre_approved_pre_confirmed(self): # A moderation-requiring un-subscription policy plus a pre-appvoed # address means the user gets un-subscribed to the mailing list without # any further confirmations or approvals. @@ -201,14 +201,12 @@ class TestUnSubscriptionWorkflow(unittest.TestCase): self.assertEqual(workflow.token_owner, TokenOwner.no_one) def test_do_unsubscription_cleanups(self): - # Once the user is un-subscribed, the token and its associated pending + # Once the user is unsubscribed, the token and its associated pending # database record will be removed from the database. self._mlist.unsubscription_policy = SubscriptionPolicy.open workflow = UnSubscriptionWorkflow(self._mlist, self.anne, pre_approved=True, pre_confirmed=True) - # Cache the token. - token = workflow.token # Run the workflow. list(workflow) # Anne is now un-subscribed from the list. @@ -217,13 +215,6 @@ class TestUnSubscriptionWorkflow(unittest.TestCase): # Workflow is done, so it has no token. self.assertIsNone(workflow.token) self.assertEqual(workflow.token_owner, TokenOwner.no_one) - # The pendable associated with the token as been evicted. - self.assertIsNone(getUtility(IPendings).confirm(token, expunge=False)) - # There is no workflow associated with the token. This shows up as an - # exception when trying to restore the workflow. - new_workflow = UnSubscriptionWorkflow(self._mlist) - new_workflow.token = token - self.assertRaises(LookupError, new_workflow.restore) def test_moderator_approves(self): # The workflow runs until moderator approval is required, at which |
