1 # Copyright (C) 2015 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18 """Test the `mailman import21` subcommand."""
27 from mailman
.app
.lifecycle
import create_list
28 from mailman
.commands
.cli_import
import Import21
29 from mailman
.testing
.layers
import ConfigLayer
30 from pkg_resources
import resource_filename
31 from unittest
.mock
import patch
36 listname
= ['test@example.com']
38 resource_filename('mailman.testing', 'config-with-instances.pck'),
43 class TestImport(unittest
.TestCase
):
47 self
.command
= Import21()
48 self
.args
= FakeArgs()
49 self
.mlist
= create_list('test@example.com')
51 @patch('mailman.commands.cli_import.import_config_pck')
52 def test_process_pickle_with_bounce_info(self
, import_config_pck
):
53 # The sample data contains Mailman 2 bounce info, represented as
54 # _BounceInfo instances. We throw these away when importing to
55 # Mailman 3, but we have to fake the instance's classes, otherwise
56 # unpickling the dictionaries will fail.
58 self
.command
.process(self
.args
)
59 except ImportError as error
:
60 self
.fail('The pickle failed loading: {}'.format(error
))
61 self
.assertTrue(import_config_pck
.called
)