Merge "Fix nested template genearation when attribute path is not string"

This commit is contained in:
Zuul
2018-01-19 16:13:56 +00:00
committed by Gerrit Code Review
6 changed files with 24 additions and 3 deletions

View File

@@ -226,7 +226,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
output_name = attr
else:
key, path = attr[0], list(attr[1:])
output_name = ', '.join(attr)
output_name = ', '.join(six.text_type(a) for a in attr)
if key.startswith("resource."):
keycomponents = key.split('.', 2)

View File

@@ -166,7 +166,7 @@ class ResourceChain(stack_resource.StackResource):
output_name = attr
else:
key, path = attr[0], list(attr[1:])
output_name = ', '.join(attr)
output_name = ', '.join(six.text_type(a) for a in attr)
if key.startswith("resource."):
keycomponents = key.split('.', 2)

View File

@@ -487,7 +487,7 @@ class ResourceGroup(stack_resource.StackResource):
output_name = attr
else:
key, path = attr[0], list(attr[1:])
output_name = ', '.join(attr)
output_name = ', '.join(six.text_type(a) for a in attr)
if key.startswith("resource."):
keycomponents = key.split('.', 2)

View File

@@ -42,6 +42,13 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
self.assertRaises(exception.StackValidationFailed,
stack['my-group'].validate)
def test_validate_reference_attr_with_none_ref(self):
stack = utils.parse_stack(self.parsed)
group = stack['my-group']
self.patchobject(group, 'referenced_attrs',
return_value=set([('something', None)]))
self.assertIsNone(group.validate())
class TestScalingGroupTags(common.HeatTestCase):
def setUp(self):

View File

@@ -129,6 +129,12 @@ class ResourceChainTest(common.HeatTestCase):
chain = self._create_chain(TEMPLATE)
chain.validate_nested_stack()
def test_validate_reference_attr_with_none_ref(self):
chain = self._create_chain(TEMPLATE)
self.patchobject(chain, 'referenced_attrs',
return_value=set([('config', None)]))
self.assertIsNone(chain.validate())
def test_validate_incompatible_properties(self):
# Tests a resource in the chain that does not support the properties
# specified to each resource.

View File

@@ -515,6 +515,14 @@ class ResourceGroupTest(common.HeatTestCase):
resgrp = resource_group.ResourceGroup('test', snip, stack)
self.assertIsNone(resgrp.validate())
def test_validate_reference_attr_with_none_ref(self):
stack = utils.parse_stack(template_attr)
snip = stack.t.resource_definitions(stack)['group1']
resgrp = resource_group.ResourceGroup('test', snip, stack)
self.patchobject(resgrp, 'referenced_attrs',
return_value=set([('nested_dict', None)]))
self.assertIsNone(resgrp.validate())
def test_invalid_removal_policies_nolist(self):
"""Test that error raised for malformed removal_policies."""
tmp = copy.deepcopy(template)