diff options
-rw-r--r-- | heatclient/common/utils.py | 2 | ||||
-rw-r--r-- | heatclient/tests/test_shell.py | 42 | ||||
-rw-r--r-- | heatclient/tests/test_utils.py | 2 | ||||
-rw-r--r-- | heatclient/v1/shell.py | 6 |
4 files changed, 47 insertions, 5 deletions
diff --git a/heatclient/common/utils.py b/heatclient/common/utils.py index fb9400d..901b526 100644 --- a/heatclient/common/utils.py +++ b/heatclient/common/utils.py @@ -41,7 +41,7 @@ def link_formatter(links): def json_formatter(js): - return jsonutils.dumps(js, indent=2) + return jsonutils.dumps(js, indent=2, ensure_ascii=False) def text_wrap_formatter(d): diff --git a/heatclient/tests/test_shell.py b/heatclient/tests/test_shell.py index 0230da4..088fd81 100644 --- a/heatclient/tests/test_shell.py +++ b/heatclient/tests/test_shell.py @@ -598,6 +598,11 @@ class ShellTestUserPass(ShellBase): "output_key": "output2", "description": "test output 2", }, + { + "output_value": u"test\u2665", + "output_key": "output_uni", + "description": "test output unicode", + }, ], "creation_time": "2012-10-25T01:58:47Z" }} @@ -616,7 +621,7 @@ class ShellTestUserPass(ShellBase): def test_output_list(self): self._output_fake_response() list_text = self.shell('output-list teststack/1') - for r in ['output1', 'output2']: + for r in ['output1', 'output2', 'output_uni']: self.assertRegexpMatches(list_text, r) def test_output_show(self): @@ -624,6 +629,11 @@ class ShellTestUserPass(ShellBase): list_text = self.shell('output-show teststack/1 output1') self.assertRegexpMatches(list_text, 'value1') + def test_output_show_unicode(self): + self._output_fake_response() + list_text = self.shell('output-show teststack/1 output_uni') + self.assertRegexpMatches(list_text, u'test\u2665') + def test_template_show_cfn(self): self._script_keystone_client() template_data = open(os.path.join(TEST_VAR_DIR, @@ -651,6 +661,36 @@ class ShellTestUserPass(ShellBase): for r in required: self.assertRegexpMatches(show_text, r) + def test_template_show_cfn_unicode(self): + self._script_keystone_client() + resp_dict = {"AWSTemplateFormatVersion": "2010-09-09", + "Description": u"test\u2665", + "Outputs": {}, + "Resources": {}, + "Parameters": {}} + resp = fakes.FakeHTTPResponse( + 200, + 'OK', + {'content-type': 'application/json'}, + jsonutils.dumps(resp_dict)) + http.HTTPClient.json_request( + 'GET', '/stacks/teststack/template').AndReturn((resp, resp_dict)) + + self.m.ReplayAll() + + show_text = self.shell('template-show teststack') + required = [ + '{', + ' "AWSTemplateFormatVersion": "2010-09-09"', + ' "Outputs": {}', + ' "Parameters": {}', + u' "Description": "test\u2665"', + ' "Resources": {}', + '}' + ] + for r in required: + self.assertRegexpMatches(show_text, r) + def test_template_show_hot(self): self._script_keystone_client() resp_dict = {"heat_template_version": "2013-05-23", diff --git a/heatclient/tests/test_utils.py b/heatclient/tests/test_utils.py index 7039509..bd8d55d 100644 --- a/heatclient/tests/test_utils.py +++ b/heatclient/tests/test_utils.py @@ -107,6 +107,8 @@ class shellTest(testtools.TestCase): self.assertEqual('{}', utils.json_formatter({})) self.assertEqual('{\n "foo": "bar"\n}', utils.json_formatter({"foo": "bar"})) + self.assertEqual(u'{\n "Uni": "test\u2665"\n}', + utils.json_formatter({"Uni": u"test\u2665"})) def test_text_wrap_formatter(self): self.assertEqual('', utils.text_wrap_formatter(None)) diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py index 921ff7b..89ede40 100644 --- a/heatclient/v1/shell.py +++ b/heatclient/v1/shell.py @@ -469,7 +469,7 @@ def do_output_show(hc, args): else: return - print (jsonutils.dumps(value, indent=2)) + print (jsonutils.dumps(value, indent=2, ensure_ascii=False)) def do_resource_type_list(hc, args={}): @@ -513,7 +513,7 @@ def do_template_show(hc, args): if 'heat_template_version' in template: print(yaml.safe_dump(template, indent=2)) else: - print(jsonutils.dumps(template, indent=2)) + print(jsonutils.dumps(template, indent=2, ensure_ascii=False)) @utils.arg('-u', '--template-url', metavar='<URL>', @@ -556,7 +556,7 @@ def do_template_validate(hc, args): } validation = hc.stacks.validate(**fields) - print(jsonutils.dumps(validation, indent=2)) + print(jsonutils.dumps(validation, indent=2, ensure_ascii=False)) @utils.arg('id', metavar='<NAME or ID>', |