Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core

Commits:
7e7e317a by Mark Sapiro at 2018-08-11T19:23:09Z
Import autorespond_postings and autorespond_admin correctly.

- - - - -
d87980b0 by Mark Sapiro at 2018-08-11T21:03:53Z
Merge branch 'import' into 'master'

Import autorespond settings correctly.

Closes #505

See merge request mailman/mailman!409
- - - - -


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
=====================================
@@ -16,6 +16,8 @@ Command line
 ------------
 * The ``mailman import21`` command properly converts all acceptable_aliases
   to regexps.  (Closes #496)
+* The ``mailman import21`` command correctly converts autorespond_* settings.
+  (Closes #505)
 
 Bugs
 ----
@@ -24,6 +26,7 @@ Bugs
 * Autoresponses to posts and -owner and -request messages now work.
   (Closes #504)
 
+
 3.2.0 -- "La Villa Strangiato"
 ==============================
 (2018-07-10)


=====================================
src/mailman/utilities/importer.py
=====================================
@@ -87,6 +87,12 @@ def list_members_to_unicode(value):
     return [bytes_to_str(item) for item in value]
 
 
+def autoresponder_mapping(value):
+    if value:
+        return ResponseAction.respond_and_continue
+    return ResponseAction.none
+
+
 def dmarc_action_mapping(value):
     # Convert dmarc_moderation_action to a DMARCMitigateAction enum.
     # 2.1 actions are 0==accept, 1==Munge From, 2==Wrap Message,
@@ -175,8 +181,8 @@ enabled: yes
 # Attributes in Mailman 2 which have a different type in Mailman 3.  Some
 # types (e.g. bools) are autodetected from their SA column types.
 TYPES = dict(
-    autorespond_owner=ResponseAction,
-    autorespond_postings=ResponseAction,
+    autorespond_owner=autoresponder_mapping,
+    autorespond_postings=autoresponder_mapping,
     autorespond_requests=ResponseAction,
     autoresponse_grace_period=days_to_delta,
     bounce_info_stale_after=seconds_to_delta,


=====================================
src/mailman/utilities/tests/test_import.py
=====================================
@@ -136,6 +136,73 @@ class TestBasicImport(unittest.TestCase):
         self.assertEqual(self._mlist.autorespond_owner, ResponseAction.none)
         self.assertEqual(self._mlist.autoresponse_owner_text, '')
 
+    def test_autoresponse_owner_yes(self):
+        # Yes -> ResponseAction.respond_and_continue
+        self._mlist.autorespond_owner = DummyEnum.val
+        self._mlist.autoresponse_owner_text = 'DUMMY'
+        self._pckdict['autorespond_admin'] = 1
+        self._pckdict['autoresponse_admin_text'] = 'Autoresponse'
+        self._import()
+        self.assertEqual(self._mlist.autorespond_owner,
+                         ResponseAction.respond_and_continue)
+        self.assertEqual(self._mlist.autoresponse_owner_text, 'Autoresponse')
+
+    def test_autoresponse_post_yes(self):
+        # Yes -> ResponseAction.respond_and_continue
+        self._mlist.autorespond_postings = DummyEnum.val
+        self._mlist.autoresponse_postings_text = 'DUMMY'
+        self._pckdict['autorespond_postings'] = 1
+        self._pckdict['autoresponse_postings_text'] = 'Autoresponse'
+        self._import()
+        self.assertEqual(self._mlist.autorespond_postings,
+                         ResponseAction.respond_and_continue)
+        self.assertEqual(self._mlist.autoresponse_postings_text,
+                         'Autoresponse')
+
+    def test_autoresponse_post_no(self):
+        # No -> ResponseAction.none
+        self._mlist.autorespond_postings = DummyEnum.val
+        self._mlist.autoresponse_postings_text = 'DUMMY'
+        self._pckdict['autorespond_postings'] = 0
+        self._import()
+        self.assertEqual(self._mlist.autorespond_postings,
+                         ResponseAction.none)
+        self.assertEqual(self._mlist.autoresponse_postings_text, '')
+
+    def test_autoresponse_request_continue(self):
+        # Yes, w/forward -> ResponseAction.respond_and_continue
+        self._mlist.autorespond_requests = DummyEnum.val
+        self._mlist.autoresponse_request_text = 'DUMMY'
+        self._pckdict['autorespond_requests'] = 2
+        self._pckdict['autoresponse_request_text'] = 'Autoresponse'
+        self._import()
+        self.assertEqual(self._mlist.autorespond_requests,
+                         ResponseAction.respond_and_continue)
+        self.assertEqual(self._mlist.autoresponse_request_text,
+                         'Autoresponse')
+
+    def test_autoresponse_request_discard(self):
+        # Yes, w/discard -> ResponseAction.respond_and_discard
+        self._mlist.autorespond_requests = DummyEnum.val
+        self._mlist.autoresponse_request_text = 'DUMMY'
+        self._pckdict['autorespond_requests'] = 1
+        self._pckdict['autoresponse_request_text'] = 'Autoresponse'
+        self._import()
+        self.assertEqual(self._mlist.autorespond_requests,
+                         ResponseAction.respond_and_discard)
+        self.assertEqual(self._mlist.autoresponse_request_text,
+                         'Autoresponse')
+
+    def test_autoresponse_request_no(self):
+        # No -> ResponseAction.none
+        self._mlist.autorespond_requests = DummyEnum.val
+        self._mlist.autoresponse_request_text = 'DUMMY'
+        self._pckdict['autorespond_requests'] = 0
+        self._import()
+        self.assertEqual(self._mlist.autorespond_requests,
+                         ResponseAction.none)
+        self.assertEqual(self._mlist.autoresponse_request_text, '')
+
     def test_administrativia(self):
         self._mlist.administrivia = None
         self._import()



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/726e2bb5f9e634a38b817549127feca5d63ca4fc...d87980b017f9c4d7eb18554cf408dc363b37d394

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/726e2bb5f9e634a38b817549127feca5d63ca4fc...d87980b017f9c4d7eb18554cf408dc363b37d394
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