string parameter type mismatch

Added the new method to convert
numeric value to string.

Change-Id: Ib0b4273d1a77ee599bf21fe8a1059869ade98aef
Closes-Bug: #1567373
This commit is contained in:
hmonika 2016-04-22 18:58:46 +05:30 committed by monika
parent 5672c4649e
commit ea6ae8bfe1
3 changed files with 19 additions and 2 deletions

View File

@ -195,7 +195,7 @@ class Schema(collections.Mapping):
elif self.type == self.NUMBER:
return Schema.str_to_num(value)
elif self.type == self.STRING:
return str(value)
return six.text_type(value)
elif self.type == self.BOOLEAN:
return strutils.bool_from_string(str(value), strict=True)
except ValueError:

View File

@ -340,6 +340,9 @@ class StringParam(Parameter):
def _validate(self, val, context):
self.schema.validate_value(val, context)
def value(self):
return self.schema.to_schema_type(super(StringParam, self).value())
class ParsedParameter(Parameter):
"""A template parameter with cached parsed value."""

View File

@ -73,7 +73,21 @@ class ParameterTestCommon(common.HeatTestCase):
expected='True',
allowed_value=[False],
zero=False,
default=True))
default=True)),
('type_int_string', dict(p_type='String',
inst=parameters.StringParam,
value='111',
expected='111',
allowed_value=['111'],
zero='',
default='0')),
('type_string_json', dict(p_type='Json',
inst=parameters.JsonParam,
value={'1': 1},
expected='{"1": 1}',
allowed_value=[{'2': '2'}],
zero={},
default={'3': 3}))
]
def test_new_param(self):