summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAurélien Bompard2015-03-26 16:59:04 +0100
committerAurélien Bompard2015-03-26 16:59:04 +0100
commitbc62deedc74139a3894127996b0cf5b7eb34a9c1 (patch)
tree3da556f92643725eb331dbef8899283664ecf92b /src
parent56c852bff0aa8c92aff92be5888fc6e4d50b5704 (diff)
downloadmailman-bc62deedc74139a3894127996b0cf5b7eb34a9c1.tar.gz
mailman-bc62deedc74139a3894127996b0cf5b7eb34a9c1.tar.zst
mailman-bc62deedc74139a3894127996b0cf5b7eb34a9c1.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/commands/cli_import.py2
-rw-r--r--src/mailman/commands/tests/test_import.py56
-rw-r--r--src/mailman/testing/config-with-instances.pckbin0 -> 4667 bytes
3 files changed, 58 insertions, 0 deletions
diff --git a/src/mailman/commands/cli_import.py b/src/mailman/commands/cli_import.py
index 344d5baee..a28ee5cba 100644
--- a/src/mailman/commands/cli_import.py
+++ b/src/mailman/commands/cli_import.py
@@ -45,6 +45,8 @@ class Bouncer:
@contextmanager
def hacked_sys_modules():
+ #yield
+ #return
assert 'Mailman.Bouncer' not in sys.modules
sys.modules['Mailman.Bouncer'] = Bouncer
try:
diff --git a/src/mailman/commands/tests/test_import.py b/src/mailman/commands/tests/test_import.py
new file mode 100644
index 000000000..e9ffbb7e5
--- /dev/null
+++ b/src/mailman/commands/tests/test_import.py
@@ -0,0 +1,56 @@
+# Copyright (C) 2011-2015 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""Test the `mailman import21` subcommand."""
+
+__all__ = [
+ 'TestImport',
+ ]
+
+
+import unittest
+
+from mailman.app.lifecycle import create_list
+from mailman.commands.cli_import import Import21
+from mailman.testing.layers import ConfigLayer
+from mock import patch
+from pkg_resources import resource_filename
+
+
+
+class FakeArgs:
+ listname = ["test@example.com"]
+ pickle_file = [resource_filename(
+ 'mailman.testing', 'config-with-instances.pck')]
+
+
+
+class TestImport(unittest.TestCase):
+ layer = ConfigLayer
+
+ def setUp(self):
+ self.command = Import21()
+ self.args = FakeArgs()
+ self.mlist = create_list('test@example.com')
+
+ @patch("mailman.commands.cli_import.import_config_pck")
+ def test_process(self, import_config_pck):
+ try:
+ self.command.process(self.args)
+ except ImportError:
+ self.fail("The pickle failed loading")
+ self.assertTrue(import_config_pck.called)
diff --git a/src/mailman/testing/config-with-instances.pck b/src/mailman/testing/config-with-instances.pck
new file mode 100644
index 000000000..b5173f58f
--- /dev/null
+++ b/src/mailman/testing/config-with-instances.pck
Binary files differ