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
This commit is contained in:
Darja Shakhray
2015-07-27 15:21:32 +03:00
parent ec0f2dfd85
commit 22868aa9bb
2 changed files with 4 additions and 3 deletions

View File

@@ -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

View File

@@ -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):