~abompard/mailman/import21

« back to all changes in this revision

Viewing changes to src/mailman/utilities/tests/test_import.py

  • Committer: Aurélien Bompard
  • Date: 2013-09-20 16:27:49 UTC
  • Revision ID: aurelien@bompard.org-20130920162749-0pv1wdnz8jwq0ss0
When importing from 2.1, handle the archiving policy

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from mailman.app.lifecycle import create_list, remove_list
32
32
from mailman.testing.layers import ConfigLayer
33
33
from mailman.utilities.importer import import_config_pck
 
34
from mailman.interfaces.archiver import ArchivePolicy
34
35
from pkg_resources import resource_filename
35
36
 
36
37
 
68
69
        self._import()
69
70
        self.assertTrue(self._mlist.allow_list_posts)
70
71
        self.assertTrue(self._mlist.include_rfc2369_headers)
 
72
 
 
73
 
 
74
 
 
75
class TestArchiveImport(unittest.TestCase):
 
76
    # The mlist.archive_policy gets set from the old list's archive and
 
77
    # archive_private values
 
78
 
 
79
    layer = ConfigLayer
 
80
 
 
81
    def setUp(self):
 
82
        self._mlist = create_list('blank@example.com')
 
83
        self._mlist.archive_policy = "INITIAL-TEST-VALUE"
 
84
 
 
85
    def tearDown(self):
 
86
        remove_list(self._mlist)
 
87
 
 
88
    def _do_test(self, pckdict, expected):
 
89
        import_config_pck(self._mlist, pckdict)
 
90
        self.assertEqual(self._mlist.archive_policy, expected)
 
91
 
 
92
    def test_public(self):
 
93
        self._do_test({ "archive": True, "archive_private": False },
 
94
                      ArchivePolicy.public)
 
95
 
 
96
    def test_private(self):
 
97
        self._do_test({ "archive": True, "archive_private": True },
 
98
                      ArchivePolicy.private)
 
99
 
 
100
    def test_no_archive(self):
 
101
        self._do_test({ "archive": False, "archive_private": False },
 
102
                      ArchivePolicy.never)