Barry Warsaw pushed to branch master at mailman / Mailman

Commits:
abab1cb4 by Barry Warsaw at 2017-01-16T00:24:41-05:00
Fix confirmation of unsubscription requests.  (Closes: #294)

- - - - -
1893d9ab by Barry Warsaw at 2017-01-16T14:56:27+00:00
Merge branch 'issue294' into 'master'

Fix confirmation of unsubscription requests

Closes #294

See merge request !236
- - - - -


4 changed files:

- src/mailman/commands/eml_confirm.py
- src/mailman/commands/eml_membership.py
- src/mailman/commands/tests/test_confirm.py
- src/mailman/docs/NEWS.rst


Changes:

=====================================
src/mailman/commands/eml_confirm.py
=====================================
--- a/src/mailman/commands/eml_confirm.py
+++ b/src/mailman/commands/eml_confirm.py
@@ -53,7 +53,10 @@ class Confirm:
                 mlist).confirm(token)
             if new_token is None:
                 assert token_owner is TokenOwner.no_one, token_owner
-                assert member is not None, member
+                # We can't assert anything about member.  It will be None when
+                # the workflow we're confirming is an unsubscription request,
+                # and non-None when we're confirming a subscription request.
+                # This class doesn't know which is happening.
                 succeeded = True
             elif token_owner is TokenOwner.moderator:
                 # This must have been a confirm-then-moderator subscription.


=====================================
src/mailman/commands/eml_membership.py
=====================================
--- a/src/mailman/commands/eml_membership.py
+++ b/src/mailman/commands/eml_membership.py
@@ -198,7 +198,7 @@ You may be asked to confirm your request.""")
         already_left.add(email)
         manager = ISubscriptionManager(mlist)
         token, token_owner, member = manager.unregister(user_address)
-        person = formataddr((user.display_name, email))   # noqa
+        person = formataddr((user.display_name, email))   # noqa: F841
         if member is None:
             print(_('$person left $mlist.fqdn_listname'), file=results)
         else:


=====================================
src/mailman/commands/tests/test_confirm.py
=====================================
--- a/src/mailman/commands/tests/test_confirm.py
+++ b/src/mailman/commands/tests/test_confirm.py
@@ -28,13 +28,15 @@ from mailman.interfaces.mailinglist import 
SubscriptionPolicy
 from mailman.interfaces.subscriptions import ISubscriptionManager
 from mailman.interfaces.usermanager import IUserManager
 from mailman.runners.command import CommandRunner, Results
-from mailman.testing.helpers import get_queue_messages, make_testable_runner
+from mailman.testing.helpers import (
+    get_queue_messages, make_testable_runner,
+    specialized_message_from_string as mfs, subscribe)
 from mailman.testing.layers import ConfigLayer
 from zope.component import getUtility
 
 
-class TestConfirm(unittest.TestCase):
-    """Test the `confirm` command."""
+class TestConfirmJoin(unittest.TestCase):
+    """Test the `confirm` command when joining a mailing list."""
 
     layer = ConfigLayer
 
@@ -72,6 +74,30 @@ class TestConfirm(unittest.TestCase):
         get_queue_messages('virgin', expected_count=0)
 
 
+class TestConfirmLeave(unittest.TestCase):
+    """Test the `confirm` command when leaving a mailing list."""
+
+    layer = ConfigLayer
+
+    def setUp(self):
+        self._mlist = create_list('t...@example.com')
+        anne = subscribe(self._mlist, 'Anne', email='a...@example.com')
+        self._token, token_owner, member = ISubscriptionManager(
+            self._mlist).unregister(anne.address)
+
+    def test_confirm_leave(self):
+        msg = mfs("""\
+From: Anne Person <a...@example.com>
+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('a...@example.com')
+        self.assertIsNone(member)
+
+
 class TestEmailResponses(unittest.TestCase):
     """Test the `confirm` command through the command runner."""
 


=====================================
src/mailman/docs/NEWS.rst
=====================================
--- a/src/mailman/docs/NEWS.rst
+++ b/src/mailman/docs/NEWS.rst
@@ -105,6 +105,7 @@ Bugs
    Abhilash Raj.  (Closes: #214)
  * Messages were shunted when non-ASCII characters appeared in a mailing
    list's description.  Given by Mark Sapiro.  (Closes: #215)
+ * Fix confirmation of unsubscription requests.  (Closes: #294)
 
 Configuration
 -------------



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/a5149b7167fb8c70beaa44a7dca287323a752131...1893d9abbaf99c27065f79ea10bd6d2914972cac
_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to