diff options
Diffstat (limited to 'src/mailman/utilities/tests/test_import.py')
| -rw-r--r-- | src/mailman/utilities/tests/test_import.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py index c8da32e42..b64da7501 100644 --- a/src/mailman/utilities/tests/test_import.py +++ b/src/mailman/utilities/tests/test_import.py @@ -21,6 +21,7 @@ from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'TestArchiveImport', 'TestBasicImport', ] @@ -29,6 +30,7 @@ import cPickle import unittest from mailman.app.lifecycle 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): self._import() self.assertTrue(self._mlist.allow_list_posts) self.assertTrue(self._mlist.include_rfc2369_headers) + + + +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('blank@example.com') + 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), + ArchivePolicy.public) + + def test_private(self): + self._do_test(dict(archive=True, archive_private=True), + ArchivePolicy.private) + + def test_no_archive(self): + self._do_test(dict(archive=False, archive_private=False), + ArchivePolicy.never) + + 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), + ArchivePolicy.never) + + 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) |
