summaryrefslogtreecommitdiff
path: root/src/mailman/chains/tests/test_hold.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-05-11 21:29:18 -0400
committerBarry Warsaw2015-05-11 21:29:18 -0400
commite8514abd591504f70c131d08ec9fd2a53c914e9e (patch)
tree6cc26448b1cd1fb638df7a7d6d7528aec90d2161 /src/mailman/chains/tests/test_hold.py
parentd6e93bd29f06f0b4d73e455c0170ee1616a17e21 (diff)
downloadmailman-e8514abd591504f70c131d08ec9fd2a53c914e9e.tar.gz
mailman-e8514abd591504f70c131d08ec9fd2a53c914e9e.tar.zst
mailman-e8514abd591504f70c131d08ec9fd2a53c914e9e.zip
Diffstat (limited to 'src/mailman/chains/tests/test_hold.py')
-rw-r--r--src/mailman/chains/tests/test_hold.py47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/mailman/chains/tests/test_hold.py b/src/mailman/chains/tests/test_hold.py
index b896157c4..1643b6ce3 100644
--- a/src/mailman/chains/tests/test_hold.py
+++ b/src/mailman/chains/tests/test_hold.py
@@ -19,6 +19,7 @@
__all__ = [
'TestAutorespond',
+ 'TestHoldChain',
]
@@ -26,9 +27,12 @@ import unittest
from mailman.app.lifecycle import create_list
from mailman.chains.hold import autorespond_to_sender
+from mailman.core.chains import process as process_chain
from mailman.interfaces.autorespond import IAutoResponseSet, Response
from mailman.interfaces.usermanager import IUserManager
-from mailman.testing.helpers import configuration, get_queue_messages
+from mailman.testing.helpers import (
+ configuration, get_queue_messages,
+ specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
from zope.component import getUtility
@@ -86,3 +90,44 @@ further responses today. Please try again tomorrow.
If you believe this message is in error, or if you have any questions,
please contact the list owner at test-owner@example.com.""")
+
+
+
+class TestHoldChain(unittest.TestCase):
+ """Test the hold chain code."""
+
+ layer = ConfigLayer
+
+ def setUp(self):
+ self._mlist = create_list('test@example.com')
+
+ def test_hold_chain(self):
+ msg = mfs("""\
+From: anne@example.com
+To: test@example.com
+Subject: A message
+Message-ID: <ant>
+MIME-Version: 1.0
+
+A message body.
+""")
+ msgdata = dict(moderation_reasons=[
+ 'TEST-REASON-1',
+ 'TEST-REASON-2',
+ ])
+ process_chain(self._mlist, msg, msgdata, start_chain='hold')
+ messages = get_queue_messages('virgin')
+ self.assertEqual(len(messages), 2)
+ payloads = {}
+ for item in messages:
+ if item.msg['to'] == 'test-owner@example.com':
+ part = item.msg.get_payload(0)
+ payloads['owner'] = part.get_payload().splitlines()
+ elif item.msg['To'] == 'anne@example.com':
+ payloads['sender'] = item.msg.get_payload().splitlines()
+ else:
+ self.fail('Unexpected message: %s' % item.msg)
+ self.assertIn(' TEST-REASON-1', payloads['owner'])
+ self.assertIn(' TEST-REASON-2', payloads['owner'])
+ self.assertIn(' TEST-REASON-1', payloads['sender'])
+ self.assertIn(' TEST-REASON-2', payloads['sender'])