Merge "Using a number in str_replace causes an exception"
This commit is contained in:
commit
2ddcf04480
@ -248,7 +248,7 @@ class HOTemplate(template.Template):
|
||||
_('"params" parameter must be a dictionary'))
|
||||
for key in params.iterkeys():
|
||||
value = params.get(key, '') or ""
|
||||
text = text.replace(key, value)
|
||||
text = text.replace(key, str(value))
|
||||
return text
|
||||
|
||||
match_str_replace = lambda k, v: k in ['str_replace', 'Fn::Replace']
|
||||
|
@ -177,6 +177,18 @@ class HOTemplateTest(HeatTestCase):
|
||||
self.assertEqual(snippet_resolved,
|
||||
tmpl.resolve_replace(snippet))
|
||||
|
||||
def test_str_replace_number(self):
|
||||
"""Test str_replace function with numbers."""
|
||||
|
||||
snippet = {'str_replace': {'template': 'Template number string bar',
|
||||
'params': {'number': 1}}}
|
||||
snippet_resolved = 'Template 1 string bar'
|
||||
|
||||
tmpl = parser.Template(hot_tpl_empty)
|
||||
|
||||
self.assertEqual(snippet_resolved,
|
||||
tmpl.resolve_replace(snippet))
|
||||
|
||||
def test_str_fn_replace(self):
|
||||
"""Test Fn:Replace function."""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user