summaryrefslogtreecommitdiff
path: root/heatclient
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-17 10:53:33 +0000
committerGerrit Code Review <review@openstack.org>2016-10-17 10:53:33 +0000
commita57ea561598b7d8842bb0cf170f142a4c4430315 (patch)
treeacb33d33523e5cc855f00e08bd2a773cb7c319d7 /heatclient
parent4e59ff4376ed0b1d07a4432b40c130d5f9ed9701 (diff)
parent272c32f7ecc4b0dc16eaf893ccc534e01b45a2a1 (diff)
downloadpython-heatclient-a57ea561598b7d8842bb0cf170f142a4c4430315.tar.gz
Merge "Fix "heat output-show -F json" output format"
Diffstat (limited to 'heatclient')
-rw-r--r--heatclient/tests/unit/test_shell.py16
-rw-r--r--heatclient/v1/shell.py12
2 files changed, 19 insertions, 9 deletions
diff --git a/heatclient/tests/unit/test_shell.py b/heatclient/tests/unit/test_shell.py
index e1af879..383ee2c 100644
--- a/heatclient/tests/unit/test_shell.py
+++ b/heatclient/tests/unit/test_shell.py
@@ -2446,8 +2446,18 @@ class ShellTestUserPass(ShellBase):
self._output_fake_response('output2')
list_text = self.shell('output-show -F json teststack/1 output2')
- self.assertEqual('[\n "output", \n "value", \n "2"\n]\n',
- list_text)
+ required = [
+ '{',
+ '"output_key": "output2"',
+ '"description": "test output 2"',
+ '"output_value": \[',
+ '"output"',
+ '"value"',
+ '"2"',
+ '}'
+ ]
+ for r in required:
+ self.assertRegex(list_text, r)
def test_output_show_output2_json_with_detail(self):
self.register_keystone_auth_fixture()
@@ -2471,7 +2481,7 @@ class ShellTestUserPass(ShellBase):
self._output_fake_response('output_uni')
list_text = self.shell('output-show teststack/1 output_uni')
- self.assertEqual(u'"test\u2665"\n', list_text)
+ self.assertEqual(u'test\u2665\n', list_text)
def test_output_show_error(self):
self.register_keystone_auth_fixture()
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index 99a33f9..35a9102 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -728,7 +728,7 @@ def do_output_list(hc, args):
help=_('Name of an output to display.'))
@utils.arg('-F', '--format', metavar='<FORMAT>',
help=_('The output value format, one of: json, raw.'),
- default='json')
+ default='raw')
@utils.arg('-a', '--all', default=False, action='store_true',
help=_('Display all stack outputs.'))
@utils.arg('--with-detail', default=False, action="store_true",
@@ -771,11 +771,11 @@ def do_output_show(hc, args):
}
utils.print_dict(output['output'], formatters=formatters)
else:
- if (args.format == 'json'
- or isinstance(output['output']['output_value'], dict)
- or isinstance(output['output']['output_value'], list)):
- print(
- utils.json_formatter(output['output']['output_value']))
+ if args.format == 'json':
+ print(utils.json_formatter(output['output']))
+ elif (isinstance(output['output']['output_value'], dict)
+ or isinstance(output['output']['output_value'], list)):
+ print(utils.json_formatter(output['output']['output_value']))
else:
print(output['output']['output_value'])