Merge "Handle the case that stack has no "outputs""

This commit is contained in:
Jenkins 2015-12-15 01:10:30 +00:00 committed by Gerrit Code Review
commit d2c966d425
2 changed files with 11 additions and 5 deletions

View File

@ -135,7 +135,7 @@ class OutputMapping(object):
return self.heat_output == output_key
def get_output_value(self, stack):
for output in stack.outputs:
for output in stack.to_dict().get('outputs', []):
if output['output_key'] == self.heat_output:
return output['output_value']

View File

@ -122,7 +122,7 @@ class TemplateDefinitionTestCase(base.TestCase):
]
mock_stack = mock.MagicMock()
mock_stack.outputs = heat_outputs
mock_stack.to_dict.return_value = {'outputs': heat_outputs}
output = tdef.OutputMapping('key1')
value = output.get_output_value(mock_stack)
@ -136,6 +136,12 @@ class TemplateDefinitionTestCase(base.TestCase):
value = output.get_output_value(mock_stack)
self.assertIsNone(value)
# verify stack with no 'outputs' attribute
mock_stack.to_dict.return_value = {}
output = tdef.OutputMapping('key1')
value = output.get_output_value(mock_stack)
self.assertIsNone(value)
def test_add_output_with_mapping_type(self):
definition = tdef.TemplateDefinition.get_template_definition(
'vm',
@ -315,7 +321,7 @@ class AtomicK8sTemplateDefinitionTestCase(base.TestCase):
"output_key": 'api_address'},
]
mock_stack = mock.MagicMock()
mock_stack.outputs = outputs
mock_stack.to_dict.return_value = {'outputs': outputs}
mock_bay = mock.MagicMock()
mock_baymodel = mock.MagicMock()
mock_baymodel.tls_disabled = tls
@ -477,7 +483,7 @@ class AtomicSwarmTemplateDefinitionTestCase(base.TestCase):
"output_key": "swarm_nodes"},
]
mock_stack = mock.MagicMock()
mock_stack.outputs = outputs
mock_stack.to_dict.return_value = {'outputs': outputs}
mock_bay = mock.MagicMock()
mock_baymodel = mock.MagicMock()
@ -523,7 +529,7 @@ class UbuntuMesosTemplateDefinitionTestCase(base.TestCase):
"output_key": "mesos_slaves"},
]
mock_stack = mock.MagicMock()
mock_stack.outputs = outputs
mock_stack.to_dict.return_value = {'outputs': outputs}
mock_bay = mock.MagicMock()
mock_baymodel = mock.MagicMock()