Commit 76efb497 authored by Barry Warsaw's avatar Barry Warsaw

* Fix importation from MM2.1 to MM3 of the archive policy. Given by Aurélien

   Bompard. (LP: #1227658)
parent 9aa16a27
......@@ -53,6 +53,8 @@ Bugs
signals. (LP: #1184376)
* Add `subject_prefix` to the `IMailingList` interface, and clarify the
docstring for `display_name`. (LP: #1181498)
* Fix importation from MM2.1 to MM3 of the archive policy. Given by Aurélien
Bompard. (LP: #1227658)
3.0 beta 3 -- "Here Again"
......@@ -33,6 +33,7 @@ from mailman.interfaces.autorespond import ResponseAction
from mailman.interfaces.digests import DigestFrequency
from mailman.interfaces.mailinglist import Personalization, ReplyToMunging
from mailman.interfaces.nntp import NewsgroupModeration
from mailman.interfaces.archiver import ArchivePolicy
......@@ -90,3 +91,15 @@ def import_config_pck(mlist, config_dict):
except TypeError:
print('Type conversion error:', key, file=sys.stderr)
# Handle the archiving policy. In MM2.1 there were two boolean options
# but only three of the four possible states were valid. Now there's just
# an enum.
if config_dict.get('archive'):
# For maximum safety, if for some strange reason there's no
# archive_private key, treat the list as having private archives.
if config_dict.get('archive_private', True):
mlist.archive_policy = ArchivePolicy.private
mlist.archive_policy = ArchivePolicy.public
mlist.archive_policy = ArchivePolicy.never
......@@ -21,6 +21,7 @@ from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
......@@ -29,6 +30,7 @@ import cPickle
import unittest
from import create_list, remove_list
from mailman.interfaces.archiver import ArchivePolicy
from mailman.testing.layers import ConfigLayer
from mailman.utilities.importer import import_config_pck
from pkg_resources import resource_filename
......@@ -68,3 +70,56 @@ class TestBasicImport(unittest.TestCase):
class TestArchiveImport(unittest.TestCase):
"""Test conversion of the archive policies.
Mailman 2.1 had two variables `archive` and `archive_private`. Now
there's just a single `archive_policy` enum.
layer = ConfigLayer
def setUp(self):
self._mlist = create_list('[email protected]')
self._mlist.archive_policy = 'INITIAL-TEST-VALUE'
def _do_test(self, pckdict, expected):
import_config_pck(self._mlist, pckdict)
self.assertEqual(self._mlist.archive_policy, expected)
def test_public(self):
self._do_test(dict(archive=True, archive_private=False),
def test_private(self):
self._do_test(dict(archive=True, archive_private=True),
def test_no_archive(self):
self._do_test(dict(archive=False, archive_private=False),
def test_bad_state(self):
# For some reason, the old list has the invalid archiving state where
# `archive` is False and `archive_private` is True. It doesn't matter
# because this still collapses to the same enum value.
self._do_test(dict(archive=False, archive_private=True),
def test_missing_archive_key(self):
# For some reason, the old list didn't have an `archive` key. We
# treat this as if no archiving is done.
self._do_test(dict(archive_private=False), ArchivePolicy.never)
def test_missing_archive_key_archive_public(self):
# For some reason, the old list didn't have an `archive` key, and it
# has weird value for archive_private. We treat this as if no
# archiving is done.
self._do_test(dict(archive_private=True), ArchivePolicy.never)
def test_missing_archive_private_key(self):
# For some reason, the old list was missing an `archive_private` key.
# For maximum safety, we treat this as private archiving.
self._do_test(dict(archive=True), ArchivePolicy.private)
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment