summaryrefslogtreecommitdiff
path: root/src/mailman/commands/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/commands/tests')
-rw-r--r--src/mailman/commands/tests/test_confirm.py32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/mailman/commands/tests/test_confirm.py b/src/mailman/commands/tests/test_confirm.py
index 650d37e29..1ef392b76 100644
--- 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('test@example.com')
+ anne = subscribe(self._mlist, 'Anne', email='anne@example.com')
+ self._token, token_owner, member = ISubscriptionManager(
+ self._mlist).unregister(anne.address)
+
+ def test_confirm_leave(self):
+ msg = mfs("""\
+From: Anne Person <anne@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('anne@example.com')
+ self.assertIsNone(member)
+
+
class TestEmailResponses(unittest.TestCase):
"""Test the `confirm` command through the command runner."""