summaryrefslogtreecommitdiff
path: root/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hp.com>2014-07-10 11:29:42 +0100
committerSamuel Merritt <sam@swiftstack.com>2014-07-21 15:27:40 -0700
commit394cb57f630b3dfdc1d5b2e172ef0f1c16b8211f (patch)
tree2442cdf3eadd1f78f0613207651ace6e11a94de8 /tests/unit/test_shell.py
parentf9ea672322cddba65bbcd5bd8bf7b83b583d4cb2 (diff)
downloadpython-swiftclient-2.2.0.tar.gz
Fix context sensitive help for info and tempurl2.2.0
Make it so that swift <cmd> --help will print the info subcommand help for info and tempurl just like all the other subcommands. Also add unit tests to verify subcommand help. Change-Id: Id3666dcf72a9727fbfda2f74c23293ada1c53aa0
Diffstat (limited to 'tests/unit/test_shell.py')
-rw-r--r--tests/unit/test_shell.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/test_shell.py b/tests/unit/test_shell.py
index 0bd7fda..daf4cd8 100644
--- a/tests/unit/test_shell.py
+++ b/tests/unit/test_shell.py
@@ -356,3 +356,25 @@ class TestShell(unittest.TestCase):
connection.return_value.get_capabilities.return_value = {'swift': None}
swiftclient.shell.main(argv)
connection.return_value.get_capabilities.assert_called_with(None)
+
+
+class TestSubcommandHelp(unittest.TestCase):
+
+ def test_subcommand_help(self):
+ for command in swiftclient.shell.commands:
+ help_var = 'st_%s_help' % command
+ self.assertTrue(help_var in vars(swiftclient.shell))
+ out = six.StringIO()
+ with mock.patch('sys.stdout', out):
+ argv = ['', command, '--help']
+ self.assertRaises(SystemExit, swiftclient.shell.main, argv)
+ expected = vars(swiftclient.shell)[help_var]
+ self.assertEqual(out.getvalue().strip('\n'), expected)
+
+ def test_no_help(self):
+ out = six.StringIO()
+ with mock.patch('sys.stdout', out):
+ argv = ['', 'bad_command', '--help']
+ self.assertRaises(SystemExit, swiftclient.shell.main, argv)
+ expected = 'no help for bad_command'
+ self.assertEqual(out.getvalue().strip('\n'), expected)