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/rest/tests | |
| 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/rest/tests')
| -rw-r--r-- | src/mailman/rest/tests/test_membership.py | 8 | ||||
| -rw-r--r-- | src/mailman/rest/tests/test_moderation.py | 5 |
2 files changed, 5 insertions, 8 deletions
diff --git a/src/mailman/rest/tests/test_membership.py b/src/mailman/rest/tests/test_membership.py index 9e5a486f3..f705fdcf6 100644 --- a/src/mailman/rest/tests/test_membership.py +++ b/src/mailman/rest/tests/test_membership.py @@ -34,7 +34,7 @@ from mailman.testing.helpers import ( from mailman.testing.layers import ConfigLayer, RESTLayer from mailman.utilities.datetime import now from urllib.error import HTTPError -from zope.component import getAdapter, getUtility +from zope.component import getUtility class TestMembership(unittest.TestCase): @@ -214,8 +214,7 @@ class TestMembership(unittest.TestCase): def test_duplicate_pending_subscription(self): # Issue #199 - a member's subscription is already pending and they try # to subscribe again. - registrar = getAdapter( - self._mlist, ISubscriptionManager, name='subscribe') + registrar = ISubscriptionManager(self._mlist) with transaction(): self._mlist.subscription_policy = SubscriptionPolicy.moderate anne = self._usermanager.create_address('anne@example.com') @@ -238,8 +237,7 @@ class TestMembership(unittest.TestCase): # Issue #199 - a member's subscription is already pending and they try # to subscribe again. Unlike above, this pend is waiting for the user # to confirm their subscription. - registrar = getAdapter( - self._mlist, ISubscriptionManager, name='subscribe') + registrar = ISubscriptionManager(self._mlist) with transaction(): self._mlist.subscription_policy = ( SubscriptionPolicy.confirm_then_moderate) diff --git a/src/mailman/rest/tests/test_moderation.py b/src/mailman/rest/tests/test_moderation.py index cbf9c9381..e0c3f1ccf 100644 --- a/src/mailman/rest/tests/test_moderation.py +++ b/src/mailman/rest/tests/test_moderation.py @@ -32,7 +32,7 @@ from mailman.testing.helpers import ( specialized_message_from_string as mfs) from mailman.testing.layers import RESTLayer from urllib.error import HTTPError -from zope.component import getAdapter, getUtility +from zope.component import getUtility class TestPostModeration(unittest.TestCase): @@ -150,8 +150,7 @@ class TestSubscriptionModeration(unittest.TestCase): def setUp(self): with transaction(): self._mlist = create_list('ant@example.com') - self._registrar = getAdapter( - self._mlist, ISubscriptionManager, name='subscribe') + self._registrar = ISubscriptionManager(self._mlist) manager = getUtility(IUserManager) self._anne = manager.create_address( 'anne@example.com', 'Anne Person') |
