Merge "Add 'resources' to error msg path if res' condition invalid"

This commit is contained in:
Jenkins 2016-08-25 22:20:33 +00:00 committed by Gerrit Code Review
commit a495438c9c
2 changed files with 8 additions and 8 deletions

View File

@ -115,7 +115,7 @@ class CommonTemplate(template.Template):
path = ''
if self.has_condition_section(res_data):
path = '.'.join([res_name, self.RES_CONDITION])
path = '.'.join([self.RESOURCES, res_name, self.RES_CONDITION])
return self.get_condition(res_data, stack, path)

View File

@ -375,16 +375,16 @@ class TestTemplateConditionParser(common.HeatTestCase):
stk = stack.Stack(self.ctx, 'test_res_invalid_condition', tmpl)
res_snippet = tmpl.t.get('resources')['r1']
ex = self.assertRaises(exception.InvalidConditionReference,
tmpl.get_condition,
res_snippet, stk, 'r1.condition')
self.assertIn('Invalid condition "invalid_cd" (in r1.condition)',
six.text_type(ex))
tmpl.get_res_condition,
stk, res_snippet, 'r1')
self.assertIn('Invalid condition "invalid_cd" '
'(in resources.r1.condition)', six.text_type(ex))
# test condition name is not string
tmpl.t['resources']['r1']['condition'] = 111
ex = self.assertRaises(exception.InvalidConditionReference,
tmpl.get_condition,
res_snippet, stk, 'r1.condition')
self.assertIn('Invalid condition "111" (in r1.condition)',
tmpl.get_res_condition,
stk, res_snippet, 'r1')
self.assertIn('Invalid condition "111" (in resources.r1.condition)',
six.text_type(ex))
def test_parse_output_condition_invalid(self):