Fix TypeError on joining list parameters
When parsing parameter of list type, convert each member to string. Change-Id: I000a664ee6b606fd2592fddd1c3a28bef79b0939 Closes-Bug: 1467139
This commit is contained in:
parent
c8af47d3cf
commit
39c3bec7df
@ -80,6 +80,9 @@ class Schema(constr.Schema):
|
||||
raise exception.InvalidSchemaError(
|
||||
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))
|
||||
for x in self.default]
|
||||
try:
|
||||
self.validate_constraints(default_value, context,
|
||||
[constr.CustomConstraint])
|
||||
@ -353,7 +356,8 @@ class CommaDelimitedListParam(Parameter, collections.Sequence):
|
||||
def parse(self, value):
|
||||
# only parse when value is not already a list
|
||||
if isinstance(value, list):
|
||||
return value
|
||||
return [encodeutils.safe_encode(six.text_type(x))
|
||||
for x in value]
|
||||
try:
|
||||
if value is not None:
|
||||
if value == '':
|
||||
|
@ -297,6 +297,13 @@ class ParameterTestSpecific(common.HeatTestCase):
|
||||
schema['Default'] = 'baz,foo,bar'
|
||||
p = new_parameter('p', schema)
|
||||
self.assertEqual('baz,foo,bar'.split(','), p.value())
|
||||
schema['AllowedValues'] = ['1', '3', '5']
|
||||
schema['Default'] = []
|
||||
p = new_parameter('p', schema, [1, 3, 5])
|
||||
self.assertEqual('1,3,5', str(p))
|
||||
schema['Default'] = [1, 3, 5]
|
||||
p = new_parameter('p', schema)
|
||||
self.assertEqual('1,3,5'.split(','), p.value())
|
||||
|
||||
def test_list_value_list_bad(self):
|
||||
schema = {'Type': 'CommaDelimitedList',
|
||||
|
Loading…
Reference in New Issue
Block a user