Correct output values when generating templates
Change-Id: Ibb41bec5c6cf4f63a5b8ab1c9a46b7219c3e46fb Closes-Bug: #1655439
This commit is contained in:
parent
71ca073a97
commit
5553a6f29c
@ -112,14 +112,12 @@ class Attribute(object):
|
||||
"""
|
||||
if template_type == 'hot':
|
||||
return {
|
||||
"value": '{"get_attr": ["%s", "%s"]}' % (resource_name,
|
||||
self.name),
|
||||
"value": {"get_attr": [resource_name, self.name]},
|
||||
"description": self.schema.description
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"Value": '{"Fn::GetAtt": ["%s", "%s"]}' % (resource_name,
|
||||
self.name),
|
||||
"Value": {"Fn::GetAtt": [resource_name, self.name]},
|
||||
"Description": self.schema.description
|
||||
}
|
||||
|
||||
|
@ -83,13 +83,23 @@ class AttributeTest(common.HeatTestCase):
|
||||
def test_as_output(self):
|
||||
"""Test that Attribute looks right when viewed as an Output."""
|
||||
expected = {
|
||||
"Value": '{"Fn::GetAtt": ["test_resource", "test1"]}',
|
||||
"Value": {"Fn::GetAtt": ["test_resource", "test1"]},
|
||||
"Description": "The first test attribute"
|
||||
}
|
||||
attr = attributes.Attribute(
|
||||
"test1", attributes.Schema("The first test attribute"))
|
||||
self.assertEqual(expected, attr.as_output("test_resource"))
|
||||
|
||||
def test_as_output_hot(self):
|
||||
"""Test that Attribute looks right when viewed as an Output."""
|
||||
expected = {
|
||||
"value": {"get_attr": ["test_resource", "test1"]},
|
||||
"description": "The first test attribute"
|
||||
}
|
||||
attr = attributes.Attribute(
|
||||
"test1", attributes.Schema("The first test attribute"))
|
||||
self.assertEqual(expected, attr.as_output("test_resource", "hot"))
|
||||
|
||||
|
||||
class AttributesTest(common.HeatTestCase):
|
||||
"""Test the Attributes class."""
|
||||
@ -152,15 +162,15 @@ class AttributesTest(common.HeatTestCase):
|
||||
"""Test that Output format works as expected."""
|
||||
expected = {
|
||||
"test1": {
|
||||
"Value": '{"Fn::GetAtt": ["test_resource", "test1"]}',
|
||||
"Value": {"Fn::GetAtt": ["test_resource", "test1"]},
|
||||
"Description": "Test attrib 1"
|
||||
},
|
||||
"test2": {
|
||||
"Value": '{"Fn::GetAtt": ["test_resource", "test2"]}',
|
||||
"Value": {"Fn::GetAtt": ["test_resource", "test2"]},
|
||||
"Description": "Test attrib 2"
|
||||
},
|
||||
"test3": {
|
||||
"Value": '{"Fn::GetAtt": ["test_resource", "test3"]}',
|
||||
"Value": {"Fn::GetAtt": ["test_resource", "test3"]},
|
||||
"Description": "Test attrib 3"
|
||||
}
|
||||
}
|
||||
@ -178,6 +188,37 @@ class AttributesTest(common.HeatTestCase):
|
||||
attributes.Attributes.as_outputs("test_resource",
|
||||
MyTestResourceClass))
|
||||
|
||||
def test_as_outputs_hot(self):
|
||||
"""Test that Output format works as expected."""
|
||||
expected = {
|
||||
"test1": {
|
||||
"value": {"get_attr": ["test_resource", "test1"]},
|
||||
"description": "Test attrib 1"
|
||||
},
|
||||
"test2": {
|
||||
"value": {"get_attr": ["test_resource", "test2"]},
|
||||
"description": "Test attrib 2"
|
||||
},
|
||||
"test3": {
|
||||
"value": {"get_attr": ["test_resource", "test3"]},
|
||||
"description": "Test attrib 3"
|
||||
}
|
||||
}
|
||||
MyTestResourceClass = mock.MagicMock()
|
||||
MyTestResourceClass.attributes_schema = {
|
||||
"test1": attributes.Schema("Test attrib 1"),
|
||||
"test2": attributes.Schema("Test attrib 2"),
|
||||
"test3": attributes.Schema("Test attrib 3"),
|
||||
"test4": attributes.Schema(
|
||||
"Test attrib 4",
|
||||
support_status=support.SupportStatus(status=support.HIDDEN))
|
||||
}
|
||||
self.assertEqual(
|
||||
expected,
|
||||
attributes.Attributes.as_outputs("test_resource",
|
||||
MyTestResourceClass,
|
||||
"hot"))
|
||||
|
||||
def test_caching_local(self):
|
||||
self.resolver.side_effect = ["value1", "value1 changed"]
|
||||
attribs = attributes.Attributes('test resource',
|
||||
|
@ -1433,15 +1433,15 @@ class ResourceTest(common.HeatTestCase):
|
||||
'Outputs': {
|
||||
'output1': {
|
||||
'Description': 'output1_desc',
|
||||
'Value': '{"Fn::GetAtt": ["TestResource", "output1"]}'
|
||||
'Value': {"Fn::GetAtt": ["TestResource", "output1"]}
|
||||
},
|
||||
'output2': {
|
||||
'Description': 'output2_desc',
|
||||
'Value': '{"Fn::GetAtt": ["TestResource", "output2"]}'
|
||||
'Value': {"Fn::GetAtt": ["TestResource", "output2"]}
|
||||
},
|
||||
'show': {
|
||||
'Description': u'Detailed information about resource.',
|
||||
'Value': '{"Fn::GetAtt": ["TestResource", "show"]}'
|
||||
'Value': {"Fn::GetAtt": ["TestResource", "show"]}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1517,15 +1517,15 @@ class ResourceTest(common.HeatTestCase):
|
||||
'outputs': {
|
||||
'output1': {
|
||||
'description': 'output1_desc',
|
||||
'value': '{"get_attr": ["TestResource", "output1"]}'
|
||||
'value': {"get_attr": ["TestResource", "output1"]}
|
||||
},
|
||||
'output2': {
|
||||
'description': 'output2_desc',
|
||||
'value': '{"get_attr": ["TestResource", "output2"]}'
|
||||
'value': {"get_attr": ["TestResource", "output2"]}
|
||||
},
|
||||
'show': {
|
||||
'description': u'Detailed information about resource.',
|
||||
'value': '{"get_attr": ["TestResource", "show"]}'
|
||||
'value': {"get_attr": ["TestResource", "show"]}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user