Merge "Return empty string when Fn::Select target is None."

This commit is contained in:
Jenkins 2013-06-11 00:30:14 +00:00 committed by Gerrit Code Review
commit c77d4d1c15
2 changed files with 6 additions and 0 deletions

View File

@ -244,6 +244,8 @@ class Template(collections.Mapping):
return strings[index]
if isinstance(strings, dict) and isinstance(index, basestring):
return strings[index]
if strings is None:
return ''
raise TypeError('Arguments to "Fn::Select" not fully resolved')

View File

@ -226,6 +226,10 @@ class TemplateTest(HeatTestCase):
data = {"Fn::Select": ["red", {"red": "robin", "re": "foo"}]}
self.assertEqual(parser.Template.resolve_select(data), "robin")
def test_select_from_none(self):
data = {"Fn::Select": ["red", None]}
self.assertEqual(parser.Template.resolve_select(data), "")
def test_select_from_dict_not_str(self):
data = {"Fn::Select": ["1", {"red": "robin", "re": "foo"}]}
self.assertRaises(TypeError, parser.Template.resolve_select,