summaryrefslogtreecommitdiff
path: root/src/mailman/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/app')
-rw-r--r--src/mailman/app/moderator.py2
-rw-r--r--src/mailman/app/subscriptions.py4
-rw-r--r--src/mailman/app/tests/test_moderation.py21
-rw-r--r--src/mailman/app/tests/test_subscriptions.py12
4 files changed, 32 insertions, 7 deletions
diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py
index c3347c1ff..9d3856f33 100644
--- a/src/mailman/app/moderator.py
+++ b/src/mailman/app/moderator.py
@@ -204,7 +204,7 @@ def hold_unsubscription(mlist, email):
msg = UserNotification(
mlist.owner_address, mlist.owner_address,
subject, text, mlist.preferred_language)
- msg.send(mlist, tomoderators=True)
+ msg.send(mlist, to_moderators=True)
return request_id
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py
index 9e915a25d..9e8d8dd9d 100644
--- a/src/mailman/app/subscriptions.py
+++ b/src/mailman/app/subscriptions.py
@@ -286,7 +286,7 @@ class SubscriptionWorkflow(_SubscriptionWorkflowCommon):
msg = UserNotification(
self.mlist.owner_address, self.mlist.owner_address,
subject, text, self.mlist.preferred_language)
- msg.send(self.mlist, tomoderators=True)
+ msg.send(self.mlist, to_moderators=True)
# The workflow must stop running here.
raise StopIteration
@@ -434,7 +434,7 @@ class UnSubscriptionWorkflow(_SubscriptionWorkflowCommon):
msg = UserNotification(
self.mlist.owner_address, self.mlist.owner_address,
subject, text, self.mlist.preferred_language)
- msg.send(self.mlist, tomoderators=True)
+ msg.send(self.mlist, to_moderators=True)
# The workflow must stop running here
raise StopIteration
diff --git a/src/mailman/app/tests/test_moderation.py b/src/mailman/app/tests/test_moderation.py
index 20584da49..bb3958cd7 100644
--- a/src/mailman/app/tests/test_moderation.py
+++ b/src/mailman/app/tests/test_moderation.py
@@ -23,6 +23,7 @@ from mailman.app.lifecycle import create_list
from mailman.app.moderator import (
handle_message, handle_unsubscription, hold_message, hold_unsubscription)
from mailman.interfaces.action import Action
+from mailman.interfaces.member import MemberRole
from mailman.interfaces.messages import IMessageStore
from mailman.interfaces.requests import IListRequests
from mailman.interfaces.subscriptions import ISubscriptionManager
@@ -31,7 +32,7 @@ from mailman.runners.incoming import IncomingRunner
from mailman.runners.outgoing import OutgoingRunner
from mailman.runners.pipeline import PipelineRunner
from mailman.testing.helpers import (
- get_queue_messages, make_testable_runner,
+ get_queue_messages, make_testable_runner, set_preferred,
specialized_message_from_string as mfs)
from mailman.testing.layers import SMTPLayer
from mailman.utilities.datetime import now
@@ -158,15 +159,29 @@ class TestUnsubscription(unittest.TestCase):
def test_unsubscribe_defer(self):
# When unsubscriptions must be approved by the moderator, but the
# moderator defers this decision.
- anne = getUtility(IUserManager).create_address(
- 'anne@example.org', 'Anne Person')
+ user_manager = getUtility(IUserManager)
+ anne = user_manager.create_address('anne@example.org', 'Anne Person')
token, token_owner, member = self._manager.register(
anne, pre_verified=True, pre_confirmed=True, pre_approved=True)
self.assertIsNone(token)
self.assertEqual(member.address.email, 'anne@example.org')
+ bart = user_manager.create_user('bart@example.com', 'Bart User')
+ address = set_preferred(bart)
+ self._mlist.subscribe(address, MemberRole.moderator)
# Now hold and handle an unsubscription request.
token = hold_unsubscription(self._mlist, 'anne@example.org')
handle_unsubscription(self._mlist, token, Action.defer)
+ items = get_queue_messages('virgin', expected_count=2)
+ # Find the moderator message.
+ for item in items:
+ if item.msg['to'] == 'test-owner@example.com':
+ break
+ else:
+ raise AssertionError('No moderator email found')
+ self.assertEqual(item.msgdata['recipients'], {'bart@example.com'})
+ self.assertEqual(
+ item.msg['subject'],
+ 'New unsubscription request from Test by anne@example.org')
def test_bogus_token(self):
# Try to handle an unsubscription with a bogus token.
diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py
index 19198307d..f7b9b584e 100644
--- a/src/mailman/app/tests/test_subscriptions.py
+++ b/src/mailman/app/tests/test_subscriptions.py
@@ -24,7 +24,7 @@ from mailman.app.lifecycle import create_list
from mailman.app.subscriptions import SubscriptionWorkflow
from mailman.interfaces.bans import IBanManager
from mailman.interfaces.mailinglist import SubscriptionPolicy
-from mailman.interfaces.member import MembershipIsBannedError
+from mailman.interfaces.member import MemberRole, MembershipIsBannedError
from mailman.interfaces.pending import IPendings
from mailman.interfaces.subscriptions import TokenOwner
from mailman.interfaces.usermanager import IUserManager
@@ -436,12 +436,22 @@ class TestSubscriptionWorkflow(unittest.TestCase):
self._mlist.admin_immed_notify = True
self._mlist.subscription_policy = SubscriptionPolicy.moderate
anne = self._user_manager.create_address(self._anne)
+ bart = self._user_manager.create_user('bart@example.com', 'Bart User')
+ address = set_preferred(bart)
+ self._mlist.subscribe(address, MemberRole.moderator)
workflow = SubscriptionWorkflow(self._mlist, anne,
pre_verified=True,
pre_confirmed=True)
# Consume the entire state machine.
list(workflow)
+ # Find the moderator message.
items = get_queue_messages('virgin', expected_count=1)
+ for item in items:
+ if item.msg['to'] == 'test-owner@example.com':
+ break
+ else:
+ raise AssertionError('No moderator email found')
+ self.assertEqual(item.msgdata['recipients'], {'bart@example.com'})
message = items[0].msg
self.assertEqual(message['From'], 'test-owner@example.com')
self.assertEqual(message['To'], 'test-owner@example.com')