Merge "Fix "heat output-show -F json" output format"
This commit is contained in:
commit
a57ea56159
|
@ -2446,8 +2446,18 @@ class ShellTestUserPass(ShellBase):
|
||||||
|
|
||||||
self._output_fake_response('output2')
|
self._output_fake_response('output2')
|
||||||
list_text = self.shell('output-show -F json teststack/1 output2')
|
list_text = self.shell('output-show -F json teststack/1 output2')
|
||||||
self.assertEqual('[\n "output", \n "value", \n "2"\n]\n',
|
required = [
|
||||||
list_text)
|
'{',
|
||||||
|
'"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):
|
def test_output_show_output2_json_with_detail(self):
|
||||||
self.register_keystone_auth_fixture()
|
self.register_keystone_auth_fixture()
|
||||||
|
@ -2471,7 +2481,7 @@ class ShellTestUserPass(ShellBase):
|
||||||
|
|
||||||
self._output_fake_response('output_uni')
|
self._output_fake_response('output_uni')
|
||||||
list_text = self.shell('output-show teststack/1 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):
|
def test_output_show_error(self):
|
||||||
self.register_keystone_auth_fixture()
|
self.register_keystone_auth_fixture()
|
||||||
|
|
|
@ -728,7 +728,7 @@ def do_output_list(hc, args):
|
||||||
help=_('Name of an output to display.'))
|
help=_('Name of an output to display.'))
|
||||||
@utils.arg('-F', '--format', metavar='<FORMAT>',
|
@utils.arg('-F', '--format', metavar='<FORMAT>',
|
||||||
help=_('The output value format, one of: json, raw.'),
|
help=_('The output value format, one of: json, raw.'),
|
||||||
default='json')
|
default='raw')
|
||||||
@utils.arg('-a', '--all', default=False, action='store_true',
|
@utils.arg('-a', '--all', default=False, action='store_true',
|
||||||
help=_('Display all stack outputs.'))
|
help=_('Display all stack outputs.'))
|
||||||
@utils.arg('--with-detail', default=False, action="store_true",
|
@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)
|
utils.print_dict(output['output'], formatters=formatters)
|
||||||
else:
|
else:
|
||||||
if (args.format == 'json'
|
if args.format == 'json':
|
||||||
or isinstance(output['output']['output_value'], dict)
|
print(utils.json_formatter(output['output']))
|
||||||
or isinstance(output['output']['output_value'], list)):
|
elif (isinstance(output['output']['output_value'], dict)
|
||||||
print(
|
or isinstance(output['output']['output_value'], list)):
|
||||||
utils.json_formatter(output['output']['output_value']))
|
print(utils.json_formatter(output['output']['output_value']))
|
||||||
else:
|
else:
|
||||||
print(output['output']['output_value'])
|
print(output['output']['output_value'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue