Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core


Commits:
7d5fdcf5 by Mark Sapiro at 2019-05-07T20:33:19Z
Import nonmember accept actions as Action.defer rather than Action.accept.

- - - - -
b3ed916a by Abhilash Raj at 2019-05-07T20:33:19Z
Merge branch 'import' into 'master'

Import nonmember accept actions as Action.defer rather than Action.accept.

Closes #579

See merge request mailman/mailman!509
- - - - -


3 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/utilities/importer.py
- src/mailman/utilities/tests/test_import.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -29,6 +29,8 @@ Command line
 ------------
 * The ``mailman import21`` command now leaves only regexps in the legacy
   ``*_these_nonmembers`` list attributes.  (Closes #588)
+* The ``mailman import21`` command now imports nonmember accept actions as
+  ``Action.defer`` rather than ``Action.accept``.  (Closes #579)
 
 REST
 ----


=====================================
src/mailman/utilities/importer.py
=====================================
@@ -134,9 +134,10 @@ def member_moderation_action_mapping(value):
 def nonmember_action_mapping(value):
     # For default_nonmember_action, which used to be called
     # generic_nonmember_action, the values were: 0==Accept, 1==Hold,
-    # 2==Reject, 3==Discard
+    # 2==Reject, 3==Discard, but note that Accept is really equivalent to
+    # what is now defer.
     return {
-        0: Action.accept,
+        0: Action.defer,
         1: Action.hold,
         2: Action.reject,
         3: Action.discard,
@@ -521,6 +522,9 @@ def import_config_pck(mlist, config_dict):
             emails = [addr
                       for addr in config_dict.get(prop_name, [])
                       if not addr.startswith('^')]
+            # MM 2.1 accept maps to MM 3 defer
+            if action_name == 'accept':
+                action_name = 'defer'
             import_roster(mlist, config_dict, emails, MemberRole.nonmember,
                           Action[action_name])
             # Only keep the regexes in the legacy list property.


=====================================
src/mailman/utilities/tests/test_import.py
=====================================
@@ -738,7 +738,7 @@ class TestMemberActionImport(unittest.TestCase):
 
     def test_nonmember_accept(self):
         self._pckdict['generic_nonmember_action'] = 0
-        self._do_test(dict(default_nonmember_action=Action.accept))
+        self._do_test(dict(default_nonmember_action=Action.defer))
 
     def test_nonmember_hold(self):
         self._pckdict['generic_nonmember_action'] = 1
@@ -1139,7 +1139,7 @@ class TestRosterImport(unittest.TestCase):
     def test_nonmembers(self):
         import_config_pck(self._mlist, self._pckdict)
         expected = {
-            'gene': Action.accept,
+            'gene': Action.defer,
             'homer': Action.hold,
             'iris': Action.reject,
             'kenny': Action.discard,
@@ -1151,6 +1151,9 @@ class TestRosterImport(unittest.TestCase):
             member = self._mlist.nonmembers.get_member(
                 '{}@example.com'.format(name))
             self.assertEqual(member.moderation_action, action)
+            # Action.defer maps from accept; map it back to get the name.
+            if action == Action.defer:
+                action = Action.accept
             # Only regexps should remain in the list property.
             list_prop = getattr(
                 self._mlist,



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/71d693654db95c3da4fff83db91b834070c3cc0a...b3ed916aa3a3ee4dda319c14762694aeaee29069

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/71d693654db95c3da4fff83db91b834070c3cc0a...b3ed916aa3a3ee4dda319c14762694aeaee29069
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to