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


Commits:
caf12d10 by Mark Sapiro at 2019-06-18T13:56:03Z
Fix utilities/importer.py to import MM 2.1's private_archive setting.

Also reverts a change to tox.ini that causes the test suite to run twice
for cov and diffcov.

- - - - -
39bce856 by Abhilash Raj at 2019-06-18T13:56:04Z
Merge branch 'fix_607' into 'master'

Fix utilities/importer.py to import MM 2.1's private_archive setting.

Closes #607

See merge request mailman/mailman!527
- - - - -


4 changed files:

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


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -39,7 +39,7 @@ Command line
 * The ``mailman import21`` command now imports nonmember accept actions as
   ``Action.defer`` rather than ``Action.accept``.  (Closes #579)
 * The ``mailman import21`` command now correctly imports ``*_these_nonmembers``
-  actions for nonmembers following a member in the list.  (closes #580)
+  actions for nonmembers following a member in the list.  (Closes #580)
 * The progress meter while ``mailman import21`` is importing rosters has been
   shortened so it no longer wraps and scrolls.  (Closes #589)
 * The ``mailman import21`` command no longer sends an email to existing owners
@@ -47,6 +47,8 @@ Command line
 * A ``mailman notify`` command has been implemented to be run by cron to  send
   periodic notices of held requests to list owners and moderators.
   (Closes #258)
+* The ``mailman import21`` command now imports ``private_roster``.
+  (Closes #607)
 
 REST
 ----


=====================================
src/mailman/utilities/importer.py
=====================================
@@ -43,6 +43,7 @@ from mailman.interfaces.member import DeliveryMode, 
DeliveryStatus, MemberRole
 from mailman.interfaces.nntp import NewsgroupModeration
 from mailman.interfaces.template import ITemplateLoader, ITemplateManager
 from mailman.interfaces.usermanager import IUserManager
+from mailman.model.roster import RosterVisibility
 from mailman.utilities.filesystem import makedirs
 from mailman.utilities.i18n import search
 from public import public
@@ -144,6 +145,17 @@ def nonmember_action_mapping(value):
         }[value]
 
 
+def member_roster_visibility_mapping(value):
+    # For member_roster_visibility, which used to be called private_roster.
+    # The values were: 0==public, 1==members, 2==admins.
+    mapping = {
+        0: RosterVisibility.public,
+        1: RosterVisibility.members,
+        2: RosterVisibility.moderators,
+        }
+    return mapping.get(value, None)
+
+
 def action_to_chain(value):
     # Converts an action number in Mailman 2.1 to the name of the corresponding
     # chain in 3.x.  The actions 'approve', 'subscribe' and 'unsubscribe' are
@@ -368,6 +380,11 @@ def import_config_pck(mlist, config_dict):
         # but .add() would not raise ValueError if address contained '@' and
         # that needs the '^' too as it could be a regexp with an '@' in it.
         alias_set.add(address)
+    # Handle roster visibility.
+    mapping = member_roster_visibility_mapping(
+        config_dict.get('private_roster', None))
+    if mapping is not None:
+        mlist.member_roster_visibility = mapping
     # Handle header_filter_rules conversion to header_matches.
     header_matches = IHeaderMatchList(mlist)
     header_filter_rules = config_dict.get('header_filter_rules', [])


=====================================
src/mailman/utilities/tests/test_import.py
=====================================
@@ -40,6 +40,7 @@ from mailman.interfaces.member import DeliveryMode, 
DeliveryStatus
 from mailman.interfaces.nntp import NewsgroupModeration
 from mailman.interfaces.template import ITemplateLoader, ITemplateManager
 from mailman.interfaces.usermanager import IUserManager
+from mailman.model.roster import RosterVisibility
 from mailman.testing.helpers import LogFileMark
 from mailman.testing.layers import ConfigLayer
 from mailman.utilities.filesystem import makedirs
@@ -1175,6 +1176,38 @@ class TestRosterImport(unittest.TestCase):
         self.assertEqual(member.moderation_action, Action.hold)
 
 
+class TestRosterVisibilityImport(unittest.TestCase):
+    """Test that member_roster_visibility is imported correctly.
+
+    Mailman 2.1 lists have a private_roster attribute to control roster
+    visibility with values 0==public, 1==members, 2==admins
+    These correspond to the Mailman 3 member_roster_visibility values
+    RosterVisibility.public, RosterVisibility.members and
+    RosterVisibility.moderators
+    """
+    layer = ConfigLayer
+
+    def setUp(self):
+        self._mlist = create_list('bl...@example.com')
+        self._mlist.member_roster_visibility = DummyEnum.val
+
+    def _do_test(self, original, expected):
+        import_config_pck(self._mlist, dict(private_roster=original))
+        self.assertEqual(self._mlist.member_roster_visibility, expected)
+
+    def test_roster_visibility_public(self):
+        self._do_test(0, RosterVisibility.public)
+
+    def test_roster_visibility_members(self):
+        self._do_test(1, RosterVisibility.members)
+
+    def test_roster_visibility_moderators(self):
+        self._do_test(2, RosterVisibility.moderators)
+
+    def test_roster_visibility_bad(self):
+        self._do_test(3, DummyEnum.val)
+
+
 class TestPreferencesImport(unittest.TestCase):
     """Preferences get imported too."""
 


=====================================
tox.ini
=====================================
@@ -5,7 +5,7 @@ skip_missing_interpreters = True
 
 [testenv]
 commands =
-    python -m nose2 -v {posargs}
+    nocov: python -m nose2 -v {posargs}
     cov,diffcov: python -m coverage run {[coverage]rc} -m nose2 {posargs}
     cov,diffcov: python -m coverage combine {[coverage]rc}
     cov: python -m coverage html {[coverage]rc}



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/a02c52038d7de00287b8bd5acdd91f8f61f28034...39bce856139295f269e4110f4aadbdf7c089c058

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/a02c52038d7de00287b8bd5acdd91f8f61f28034...39bce856139295f269e4110f4aadbdf7c089c058
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