Merge "py34: heat.tests.test_parameters"

This commit is contained in:
Jenkins 2015-09-01 10:40:12 +00:00 committed by Gerrit Code Review
commit eaf474f75d
3 changed files with 17 additions and 8 deletions

View File

@ -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 == '':

View File

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

View File

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