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:
@@ -56,7 +56,7 @@ def arg(*args, **kwargs):
|
|||||||
def schema_args(schema_getter, omit=None):
|
def schema_args(schema_getter, omit=None):
|
||||||
omit = omit or []
|
omit = omit or []
|
||||||
typemap = {
|
typemap = {
|
||||||
'string': str,
|
'string': encodeutils.safe_decode,
|
||||||
'integer': int,
|
'integer': int,
|
||||||
'boolean': strutils.bool_from_string,
|
'boolean': strutils.bool_from_string,
|
||||||
'array': list
|
'array': list
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_utils import encodeutils
|
||||||
import six
|
import six
|
||||||
# NOTE(jokke): simplified transition to py3, behaves like py2 xrange
|
# NOTE(jokke): simplified transition to py3, behaves like py2 xrange
|
||||||
from six.moves import range
|
from six.moves import range
|
||||||
@@ -152,7 +153,7 @@ class TestUtils(testtools.TestCase):
|
|||||||
decorated = utils.schema_args(schema_getter())(dummy_func)
|
decorated = utils.schema_args(schema_getter())(dummy_func)
|
||||||
arg, opts = decorated.__dict__['arguments'][0]
|
arg, opts = decorated.__dict__['arguments'][0]
|
||||||
self.assertIn('--test', arg)
|
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)
|
decorated = utils.schema_args(schema_getter('integer'))(dummy_func)
|
||||||
arg, opts = decorated.__dict__['arguments'][0]
|
arg, opts = decorated.__dict__['arguments'][0]
|
||||||
@@ -162,7 +163,7 @@ class TestUtils(testtools.TestCase):
|
|||||||
decorated = utils.schema_args(schema_getter(enum=True))(dummy_func)
|
decorated = utils.schema_args(schema_getter(enum=True))(dummy_func)
|
||||||
arg, opts = decorated.__dict__['arguments'][0]
|
arg, opts = decorated.__dict__['arguments'][0]
|
||||||
self.assertIn('--test', arg)
|
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'])
|
self.assertIn('None, opt-1, opt-2', opts['help'])
|
||||||
|
|
||||||
def test_iterable_closes(self):
|
def test_iterable_closes(self):
|
||||||
|
Reference in New Issue
Block a user