summaryrefslogtreecommitdiff
path: root/src/mailman/utilities
diff options
context:
space:
mode:
authorAurélien Bompard2015-09-11 14:31:41 +0200
committerBarry Warsaw2015-10-20 21:10:34 -0400
commited772e4fe2296460f0261a114b4f4eea3b318d6a (patch)
treee78a664f584f4bca025ee5e4e16b6efceb0b3687 /src/mailman/utilities
parent583a7639eb78dc52cf899076fef777e303101567 (diff)
downloadmailman-ed772e4fe2296460f0261a114b4f4eea3b318d6a.tar.gz
mailman-ed772e4fe2296460f0261a114b4f4eea3b318d6a.tar.zst
mailman-ed772e4fe2296460f0261a114b4f4eea3b318d6a.zip
Adapt the code and the tests to the new HeaderMatch object
Diffstat (limited to 'src/mailman/utilities')
-rw-r--r--src/mailman/utilities/importer.py6
-rw-r--r--src/mailman/utilities/tests/test_import.py13
2 files changed, 12 insertions, 7 deletions
diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py
index df0557c08..1261823fd 100644
--- a/src/mailman/utilities/importer.py
+++ b/src/mailman/utilities/importer.py
@@ -48,6 +48,7 @@ from mailman.interfaces.mailinglist import SubscriptionPolicy
from mailman.interfaces.member import DeliveryMode, DeliveryStatus, MemberRole
from mailman.interfaces.nntp import NewsgroupModeration
from mailman.interfaces.usermanager import IUserManager
+from mailman.model.mailinglist import HeaderMatch
from mailman.utilities.filesystem import makedirs
from mailman.utilities.i18n import search
from sqlalchemy import Boolean
@@ -334,7 +335,6 @@ def import_config_pck(mlist, config_dict):
# expression. Make that explicit for MM3.
alias_set.add('^' + address)
# Handle header_filter_rules conversion to header_matches
- header_matches = []
for line_patterns, action, _unused in \
config_dict.get('header_filter_rules', []):
chain = action_to_chain(action)
@@ -367,8 +367,8 @@ def import_config_pck(mlist, config_dict):
log.warning('Skipping header_filter rule because of an '
'invalid regular expression: %r', line_pattern)
continue
- header_matches.append((header, pattern, chain))
- mlist.header_matches = header_matches
+ mlist.header_matches.append(HeaderMatch(
+ header=header, pattern=pattern, chain=chain))
# Handle conversion to URIs. In MM2.1, the decorations are strings
# containing placeholders, and there's no provision for language-specific
# templates. In MM3, template locations are specified by URLs with the
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py
index 52d3469c0..e9ad29a1b 100644
--- a/src/mailman/utilities/tests/test_import.py
+++ b/src/mailman/utilities/tests/test_import.py
@@ -49,6 +49,7 @@ from mailman.interfaces.member import DeliveryMode, DeliveryStatus
from mailman.interfaces.nntp import NewsgroupModeration
from mailman.interfaces.templates import ITemplateLoader
from mailman.interfaces.usermanager import IUserManager
+from mailman.model.mailinglist import HeaderMatch
from mailman.testing.layers import ConfigLayer
from mailman.testing.helpers import LogFileMark
from mailman.utilities.filesystem import makedirs
@@ -364,7 +365,9 @@ class TestBasicImport(unittest.TestCase):
]
error_log = LogFileMark('mailman.error')
self._import()
- self.assertListEqual(self._mlist.header_matches, [
+ self.assertListEqual(
+ [ (hm.header, hm.pattern, hm.chain)
+ for hm in self._mlist.header_matches ], [
('x-spam-status', 'Yes', 'discard'),
('x-spam-status', 'Yes', 'discard'),
('x-spam-status', 'Yes.*', 'discard'),
@@ -435,9 +438,11 @@ class TestBasicImport(unittest.TestCase):
('^X-Spam-Status: Yes', 0, False),
]
self._import()
- self.assertListEqual(self._mlist.header_matches, [
- ('x-spam-status', 'Yes', None),
- ])
+ self.assertListEqual(
+ [ (hm.header, hm.pattern, hm.chain)
+ for hm in self._mlist.header_matches ],
+ [ ('x-spam-status', 'Yes', None) ]
+ )