summaryrefslogtreecommitdiff
path: root/src/mailman/chains/tests/test_headers.py
diff options
context:
space:
mode:
authorAurélien Bompard2015-09-09 15:01:13 +0200
committerBarry Warsaw2015-10-20 21:10:34 -0400
commit6a2295762adc74362ae1f2fa8704c7aba7380145 (patch)
treef21c1535e3e944d15bc9685faebd514620be1ae2 /src/mailman/chains/tests/test_headers.py
parent49d17bc04386293b3f659e24070f618f5f1b3b05 (diff)
downloadmailman-6a2295762adc74362ae1f2fa8704c7aba7380145.tar.gz
mailman-6a2295762adc74362ae1f2fa8704c7aba7380145.tar.zst
mailman-6a2295762adc74362ae1f2fa8704c7aba7380145.zip
Diffstat (limited to 'src/mailman/chains/tests/test_headers.py')
-rw-r--r--src/mailman/chains/tests/test_headers.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mailman/chains/tests/test_headers.py b/src/mailman/chains/tests/test_headers.py
index a00f9c588..cca2e041f 100644
--- a/src/mailman/chains/tests/test_headers.py
+++ b/src/mailman/chains/tests/test_headers.py
@@ -119,3 +119,35 @@ class TestHeaderChain(unittest.TestCase):
HeaderMatchRule, 'x-spam-score', '.*')
finally:
config.rules = saved_rules
+
+ def test_list_rule(self):
+ # Test that the header-match chain has the header checks from the
+ # mailing-list configuration.
+ chain = config.chains['header-match']
+ self._mlist.header_matches = [('Foo', 'a+')]
+ links = [ link for link in chain.get_links(self._mlist, Message(), {})
+ if link.rule.name != 'any' ]
+ self.assertEqual(len(links), 1)
+ self.assertEqual(links[0].action, LinkAction.defer)
+ self.assertEqual(links[0].rule.header, 'Foo')
+ self.assertEqual(links[0].rule.pattern, 'a+')
+
+ def test_list_complex_rule(self):
+ # Test that the mailing-list header-match complex rules are read
+ # properly.
+ chain = config.chains['header-match']
+ self._mlist.header_matches = [
+ ('Foo', 'a+', 'reject'),
+ ('Bar', 'b+', 'discard'),
+ ('Baz', 'z+', 'accept'),
+ ]
+ links = [ link for link in chain.get_links(self._mlist, Message(), {})
+ if link.rule.name != 'any' ]
+ self.assertEqual(len(links), 3)
+ self.assertListEqual(
+ [ (link.rule.header, link.rule.pattern, link.action, link.chain.name)
+ for link in links ],
+ [('Foo', 'a+', LinkAction.jump, 'reject'),
+ ('Bar', 'b+', LinkAction.jump, 'discard'),
+ ('Baz', 'z+', LinkAction.jump, 'accept'),
+ ])