py34: heat.tests.test_parameters
* convert to unicode instead of converting to bytes when flattening lists to strings. * test: convert to bytes before asserting to maintain py2 compatibility. partial blueprint heat-python34-support Change-Id: I7a9f40e90d829e0764d229526698a78479feeb2f
This commit is contained in:
parent
d8304bdc79
commit
4dba62a7bb
@ -81,7 +81,7 @@ class Schema(constr.Schema):
|
||||
message=_('Default must be a comma-delimited list '
|
||||
'string: %s') % err)
|
||||
elif self.type == self.LIST and isinstance(self.default, list):
|
||||
default_value = [encodeutils.safe_encode(six.text_type(x))
|
||||
default_value = [(six.text_type(x))
|
||||
for x in self.default]
|
||||
try:
|
||||
self.validate_constraints(default_value, context,
|
||||
@ -355,8 +355,7 @@ class CommaDelimitedListParam(Parameter, collections.Sequence):
|
||||
def parse(self, value):
|
||||
# only parse when value is not already a list
|
||||
if isinstance(value, list):
|
||||
return [encodeutils.safe_encode(six.text_type(x))
|
||||
for x in value]
|
||||
return [(six.text_type(x)) for x in value]
|
||||
try:
|
||||
if value is not None:
|
||||
if value == '':
|
||||
|
@ -55,11 +55,18 @@ class ParameterTestCommon(common.HeatTestCase):
|
||||
default=['d', 'e', 'f'])),
|
||||
('type_json', dict(p_type='Json',
|
||||
inst=parameters.JsonParam,
|
||||
value={'a': 1, 'b': '2'},
|
||||
expected='{"a": 1, "b": "2"}',
|
||||
value={'a': '1'},
|
||||
expected='{"a": "1"}',
|
||||
allowed_value=[{'foo': 'bar'}],
|
||||
zero={},
|
||||
default={'d': 1, 'e': 'f'})),
|
||||
default={'d': '1'})),
|
||||
('type_int_json', dict(p_type='Json',
|
||||
inst=parameters.JsonParam,
|
||||
value={'a': 1},
|
||||
expected='{"a": 1}',
|
||||
allowed_value=[{'foo': 'bar'}],
|
||||
zero={},
|
||||
default={'d': 1})),
|
||||
('type_boolean', dict(p_type='Boolean',
|
||||
inst=parameters.BooleanParam,
|
||||
value=True,
|
||||
@ -527,7 +534,7 @@ class ParametersTest(common.HeatTestCase):
|
||||
|
||||
expected = {'Foo': 'foo',
|
||||
'Bar': '42',
|
||||
'Uni': 'test\xe2\x99\xa5',
|
||||
'Uni': b'test\xe2\x99\xa5',
|
||||
'AWS::Region': 'ap-southeast-1',
|
||||
'AWS::StackId':
|
||||
'arn:openstack:heat:::stacks/{0}/{1}'.format(
|
||||
@ -535,7 +542,9 @@ class ParametersTest(common.HeatTestCase):
|
||||
'None'),
|
||||
'AWS::StackName': 'test_params'}
|
||||
|
||||
self.assertEqual(expected, params.map(str))
|
||||
mapped_params = params.map(six.text_type)
|
||||
mapped_params['Uni'] = mapped_params['Uni'].encode('utf-8')
|
||||
self.assertEqual(expected, mapped_params)
|
||||
|
||||
def test_unknown_params(self):
|
||||
user_params = {'Foo': 'wibble'}
|
||||
|
@ -123,6 +123,7 @@ heat.tests.test_nested_stack
|
||||
heat.tests.test_nokey
|
||||
heat.tests.test_notifications
|
||||
heat.tests.test_os_database
|
||||
heat.tests.test_parameters
|
||||
heat.tests.test_plugin_loader
|
||||
heat.tests.test_plugin_manager
|
||||
heat.tests.test_properties
|
||||
|
Loading…
x
Reference in New Issue
Block a user