summaryrefslogtreecommitdiff
path: root/glanceclient/tests/unit/test_shell.py
diff options
context:
space:
mode:
authorFlavio Percoco <flaper87@gmail.com>2015-09-03 13:48:28 +0200
committerErno Kuvaja <jokke@usr.fi>2015-09-09 10:47:13 +0000
commit5026774bd1b8cdd079256a21cbbb74ba687267a9 (patch)
tree11bf1dd168a54b192fe9c15942110a107df052aa /glanceclient/tests/unit/test_shell.py
parent5507d849017829a51da005737705f72e832cdc4a (diff)
downloadpython-glanceclient-5026774bd1b8cdd079256a21cbbb74ba687267a9.tar.gz
Don't make `help` require auth parameters
The `help` command was behaving a bit funky. This patch re-orders the code a bit so that the `help` command will be parsed at the very beginning before running other commands and checks. It also allows to get help without downloading/checking schemas and without requiring auth credentials (previously required by the schema operations). Change-Id: Ib7b10d4d80f15e6b75bb8644d7d916bef09413d6 Closes-bug: #1490457
Diffstat (limited to 'glanceclient/tests/unit/test_shell.py')
-rw-r--r--glanceclient/tests/unit/test_shell.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py
index 7fcdf19..9ede51e 100644
--- a/glanceclient/tests/unit/test_shell.py
+++ b/glanceclient/tests/unit/test_shell.py
@@ -153,8 +153,10 @@ class ShellTest(testutils.TestCase):
def test_help(self):
shell = openstack_shell.OpenStackImagesShell()
argstr = '--os-image-api-version 2 help'
- actual = shell.main(argstr.split())
- self.assertEqual(0, actual)
+ with mock.patch.object(shell, '_get_endpoint_and_token') as et_mock:
+ actual = shell.main(argstr.split())
+ self.assertEqual(0, actual)
+ self.assertFalse(et_mock.called)
def test_help_on_subcommand_error(self):
self.assertRaises(exc.CommandError, shell,
@@ -163,9 +165,11 @@ class ShellTest(testutils.TestCase):
def test_help_v2_no_schema(self):
shell = openstack_shell.OpenStackImagesShell()
argstr = '--os-image-api-version 2 help image-create'
- actual = shell.main(argstr.split())
- self.assertEqual(0, actual)
- self.assertNotIn('<unavailable>', actual)
+ with mock.patch.object(shell, '_get_endpoint_and_token') as et_mock:
+ actual = shell.main(argstr.split())
+ self.assertEqual(0, actual)
+ self.assertNotIn('<unavailable>', actual)
+ self.assertFalse(et_mock.called)
def test_get_base_parser(self):
test_shell = openstack_shell.OpenStackImagesShell()