summaryrefslogtreecommitdiff
path: root/src/mailman/bin/tests/test_mailman.py
diff options
context:
space:
mode:
authorBarry Warsaw2017-08-29 14:07:55 +0000
committerBarry Warsaw2017-08-29 14:07:55 +0000
commitde8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c (patch)
tree6fd2038427fbb36d8173fe338d277351cd19727b /src/mailman/bin/tests/test_mailman.py
parentf847e15407bfbf824236547bdf728a1ae00bd405 (diff)
parentae0042a90220119414f61aeb20c6b58bfacb8af2 (diff)
downloadmailman-de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c.tar.gz
mailman-de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c.tar.zst
mailman-de8c204fa40f0c4677a1b73b2ee7e3e86ce93a9c.zip
Diffstat (limited to 'src/mailman/bin/tests/test_mailman.py')
-rw-r--r--src/mailman/bin/tests/test_mailman.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mailman/bin/tests/test_mailman.py b/src/mailman/bin/tests/test_mailman.py
index 73941d468..db13166c7 100644
--- a/src/mailman/bin/tests/test_mailman.py
+++ b/src/mailman/bin/tests/test_mailman.py
@@ -29,6 +29,7 @@ from mailman.interfaces.command import ICLISubCommand
from mailman.testing.layers import ConfigLayer
from mailman.utilities.datetime import now
from mailman.utilities.modules import add_components
+from pkg_resources import resource_filename
from unittest.mock import patch
@@ -38,7 +39,19 @@ class TestMailmanCommand(unittest.TestCase):
def setUp(self):
self._command = CliRunner()
- def test_mailman_command_without_subcommand_prints_help(self):
+ def test_mailman_command_config(self):
+ config_path = resource_filename('mailman.testing', 'testing.cfg')
+ with patch('mailman.bin.mailman.initialize') as init:
+ self._command.invoke(main, ('-C', config_path, 'info'))
+ init.assert_called_once_with(config_path)
+
+ def test_mailman_command_no_config(self):
+ with patch('mailman.bin.mailman.initialize') as init:
+ self._command.invoke(main, ('info',))
+ init.assert_called_once_with(None)
+
+ @patch('mailman.bin.mailman.initialize')
+ def test_mailman_command_without_subcommand_prints_help(self, mock):
# Issue #137: Running `mailman` without a subcommand raises an
# AttributeError.
result = self._command.invoke(main)
@@ -49,14 +62,15 @@ class TestMailmanCommand(unittest.TestCase):
self.assertEqual(lines[0], 'Usage: main [OPTIONS] COMMAND [ARGS]...')
# The help output includes a list of subcommands, in sorted order.
commands = {}
- add_components('mailman.commands', ICLISubCommand, commands)
+ add_components('commands', ICLISubCommand, commands)
help_commands = list(
line.split()[0].strip()
for line in lines[-len(commands):]
)
self.assertEqual(sorted(commands), help_commands)
- def test_mailman_command_with_bad_subcommand_prints_help(self):
+ @patch('mailman.bin.mailman.initialize')
+ def test_mailman_command_with_bad_subcommand_prints_help(self, mock):
# Issue #137: Running `mailman` without a subcommand raises an
# AttributeError.
result = self._command.invoke(main, ('not-a-subcommand',))