From 22868aa9bb5b8cec38420b37ba6b6850fbb1bbc5 Mon Sep 17 00:00:00 2001 From: Darja Shakhray Date: Mon, 27 Jul 2015 15:21:32 +0300 Subject: [PATCH] Add unicode support for properties values in v2 shell This code allows to set unicode values to v2 properties. Change-Id: I5f9c29a3e458808dd95375c7557dfce0c4f09038 Closes-bug: #1475769 --- glanceclient/common/utils.py | 2 +- glanceclient/tests/unit/test_utils.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 18059bb1..8daaffff 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -56,7 +56,7 @@ def arg(*args, **kwargs): def schema_args(schema_getter, omit=None): omit = omit or [] typemap = { - 'string': str, + 'string': encodeutils.safe_decode, 'integer': int, 'boolean': strutils.bool_from_string, 'array': list diff --git a/glanceclient/tests/unit/test_utils.py b/glanceclient/tests/unit/test_utils.py index c991f3ce..18c54753 100644 --- a/glanceclient/tests/unit/test_utils.py +++ b/glanceclient/tests/unit/test_utils.py @@ -16,6 +16,7 @@ import sys import mock +from oslo_utils import encodeutils import six # NOTE(jokke): simplified transition to py3, behaves like py2 xrange from six.moves import range @@ -152,7 +153,7 @@ class TestUtils(testtools.TestCase): decorated = utils.schema_args(schema_getter())(dummy_func) arg, opts = decorated.__dict__['arguments'][0] self.assertIn('--test', arg) - self.assertEqual(str, opts['type']) + self.assertEqual(encodeutils.safe_decode, opts['type']) decorated = utils.schema_args(schema_getter('integer'))(dummy_func) arg, opts = decorated.__dict__['arguments'][0] @@ -162,7 +163,7 @@ class TestUtils(testtools.TestCase): decorated = utils.schema_args(schema_getter(enum=True))(dummy_func) arg, opts = decorated.__dict__['arguments'][0] self.assertIn('--test', arg) - self.assertEqual(str, opts['type']) + self.assertEqual(encodeutils.safe_decode, opts['type']) self.assertIn('None, opt-1, opt-2', opts['help']) def test_iterable_closes(self):