diff options
| author | Barry Warsaw | 2012-03-23 17:26:19 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2012-03-23 17:26:19 -0400 |
| commit | 1d9fdeb0e587352a3bc66a3263152614bb6085dd (patch) | |
| tree | 9d3a82618532aa7024483ca560276a0996a39935 | |
| parent | cc949e304047a65e99c6089fc417883f7c411300 (diff) | |
| download | mailman-1d9fdeb0e587352a3bc66a3263152614bb6085dd.tar.gz mailman-1d9fdeb0e587352a3bc66a3263152614bb6085dd.tar.zst mailman-1d9fdeb0e587352a3bc66a3263152614bb6085dd.zip | |
| -rw-r--r-- | src/mailman/core/pipelines.py | 29 | ||||
| -rw-r--r-- | src/mailman/core/tests/test_pipelines.py | 46 | ||||
| -rw-r--r-- | src/mailman/styles/default.py | 5 |
3 files changed, 73 insertions, 7 deletions
diff --git a/src/mailman/core/pipelines.py b/src/mailman/core/pipelines.py index 5c0eb7f71..25bb68030 100644 --- a/src/mailman/core/pipelines.py +++ b/src/mailman/core/pipelines.py @@ -15,12 +15,16 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -"""Pipeline processor.""" +"""Built-in pipelines.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'BasePipeline', + 'OwnerPipeline', + 'PostingPipeline', + 'VirginPipeline', 'initialize', 'process', ] @@ -89,11 +93,24 @@ class BasePipeline: yield handler -class BuiltInPipeline(BasePipeline): - """The built-in pipeline.""" + +class OwnerPipeline(BasePipeline): + """The built-in owner pipeline.""" + + name = 'default-owner-pipeline' + description = _('The built-in owner pipeline.') + + _default_handlers = ( + 'owner-recipients', + 'to-outgoing', + ) + + +class PostingPipeline(BasePipeline): + """The built-in posting pipeline.""" name = 'default-posting-pipeline' - description = _('The built-in pipeline.') + description = _('The built-in posting pipeline.') _default_handlers = ( 'mime-delete', @@ -139,6 +156,6 @@ def initialize(): handler.name, handler_class)) config.handlers[handler.name] = handler # Set up some pipelines. - for pipeline_class in (BuiltInPipeline, VirginPipeline): + for pipeline_class in (OwnerPipeline, PostingPipeline, VirginPipeline): pipeline = pipeline_class() config.pipelines[pipeline.name] = pipeline diff --git a/src/mailman/core/tests/test_pipelines.py b/src/mailman/core/tests/test_pipelines.py index 0cf3732c9..8f851de95 100644 --- a/src/mailman/core/tests/test_pipelines.py +++ b/src/mailman/core/tests/test_pipelines.py @@ -21,11 +21,14 @@ from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'TestOwnerPipeline', + 'TestPostingPipeline', ] import unittest +from zope.component import getUtility from zope.interface import implements from mailman.app.lifecycle import create_list @@ -33,7 +36,9 @@ from mailman.config import config from mailman.core.errors import DiscardMessage, RejectMessage from mailman.core.pipelines import process from mailman.interfaces.handler import IHandler +from mailman.interfaces.member import MemberRole from mailman.interfaces.pipeline import IPipeline +from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import ( LogFileMark, get_queue_messages, @@ -78,7 +83,7 @@ class RejectingPipeline: -class TestBuiltinPipeline(unittest.TestCase): +class TestPostingPipeline(unittest.TestCase): """Test various aspects of the built-in postings pipeline.""" layer = ConfigLayer @@ -133,3 +138,42 @@ testing messages = get_queue_messages('virgin') self.assertEqual(len(messages), 1) self.assertEqual(str(messages[0].msg['subject']), 'a test') + + + +class TestOwnerPipeline(unittest.TestCase): + """Test various aspects of the built-in owner pipeline.""" + + layer = ConfigLayer + + def setUp(self): + self._mlist = create_list('test@example.com') + user_manager = getUtility(IUserManager) + anne = user_manager.create_address('anne@example.com') + bart = user_manager.create_address('bart@example.com') + self._mlist.subscribe(anne, MemberRole.owner) + self._mlist.subscribe(bart, MemberRole.moderator) + self._msg = mfs("""\ +From: Anne Person <anne@example.org> +To: test-owner@example.com + +""") + + def test_calculate_recipients(self): + # Recipients are the administrators of the mailing list. + msgdata = dict(listname='test@example.com', + to_owner=True) + process(self._mlist, self._msg, msgdata, + pipeline_name='default-owner-pipeline') + self.assertEqual(msgdata['recipients'], set(('anne@example.com', + 'bart@example.com'))) + + def test_to_outgoing(self): + # The message, with the calculated recipients, gets put in the + # outgoing queue. + process(self._mlist, self._msg, {}, + pipeline_name='default-owner-pipeline') + messages = get_queue_messages('out', sort_on='to') + self.assertEqual(len(messages), 1) + self.assertEqual(messages[0].msgdata['recipients'], + set(('anne@example.com', 'bart@example.com'))) diff --git a/src/mailman/styles/default.py b/src/mailman/styles/default.py index e64bbe40b..18a145d3c 100644 --- a/src/mailman/styles/default.py +++ b/src/mailman/styles/default.py @@ -218,6 +218,11 @@ from: .*@uplinkpro.com # The default pipeline to send accepted messages through to the # mailing list's members. mlist.posting_pipeline = 'default-posting-pipeline' + # The processing chain that messages posted to this mailing list's + # -owner address gets processed by. + mlist.owner_chain = 'default-owner-chain' + # The default pipeline to send -owner email through. + mlist.owner_pipeline = 'default-owner-pipeline' def match(self, mailing_list, styles): """See `IStyle`.""" |
