diff options
author | Angus Salkeld <asalkeld@mirantis.com> | 2015-07-27 20:04:02 +1000 |
---|---|---|
committer | Angus Salkeld <asalkeld@mirantis.com> | 2015-07-27 20:14:52 +1000 |
commit | 413c780bb27d4ed2763f71eda27c689345711b99 (patch) | |
tree | e40fff2e5a2a91137d90a2d8a9d0c27ac3e1e089 /heat/tests/test_provider_template.py | |
parent | 72f8bc4abccf22cd2f09858de9a849896fcd2fde (diff) | |
download | heat-413c780bb27d4ed2763f71eda27c689345711b99.tar.gz |
Catch output error and re-raise them in nested stacks
stack.output() hides errors in output['error_msg']
so check there for template issues and raise InvalidTemplateAttribute
reuse the get_output() method in template_resource.py
Change-Id: Ib06a3d83807c2399f22744754e5d38498e277dfa
Diffstat (limited to 'heat/tests/test_provider_template.py')
-rw-r--r-- | heat/tests/test_provider_template.py | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/heat/tests/test_provider_template.py b/heat/tests/test_provider_template.py index 5fed02a73..5468710c1 100644 --- a/heat/tests/test_provider_template.py +++ b/heat/tests/test_provider_template.py @@ -218,7 +218,7 @@ class ProviderTemplateTest(common.HeatTestCase): definition, stack) self.assertIsNone(temp_res.validate()) - def test_attributes_missing(self): + def test_attributes_missing_based_on_class(self): provider = { 'HeatTemplateFormatVersion': '2012-12-12', 'Outputs': { @@ -248,6 +248,63 @@ class ProviderTemplateTest(common.HeatTestCase): self.assertRaises(exception.StackValidationFailed, temp_res.validate) + def test_attributes_missing_no_class(self): + provider = { + 'HeatTemplateFormatVersion': '2012-12-12', + 'Outputs': { + 'Blarg': {'Value': 'wibble'}, + }, + } + files = {'test_resource.template': json.dumps(provider)} + + env = environment.Environment() + env.load({'resource_registry': + {'DummyResource2': 'test_resource.template'}}) + stack = parser.Stack(utils.dummy_context(), 'test_stack', + template.Template(empty_template, files=files, + env=env), + stack_id=str(uuid.uuid4())) + + definition = rsrc_defn.ResourceDefinition('test_t_res', + "DummyResource2") + temp_res = template_resource.TemplateResource('test_t_res', + definition, stack) + nested = mock.Mock() + nested.outputs = {'Blarg': {'Value': 'fluffy'}} + temp_res._nested = nested + self.assertRaises(exception.InvalidTemplateAttribute, + temp_res.FnGetAtt, 'Foo') + + def test_attributes_not_parsable(self): + provider = { + 'HeatTemplateFormatVersion': '2012-12-12', + 'Outputs': { + 'Blarg': {'Value': 'wibble'}, + }, + } + files = {'test_resource.template': json.dumps(provider)} + + env = environment.Environment() + env.load({'resource_registry': + {'DummyResource': 'test_resource.template'}}) + stack = parser.Stack(utils.dummy_context(), 'test_stack', + template.Template(empty_template, files=files, + env=env), + stack_id=str(uuid.uuid4())) + + definition = rsrc_defn.ResourceDefinition('test_t_res', + "DummyResource") + temp_res = template_resource.TemplateResource('test_t_res', + definition, stack) + self.assertIsNone(temp_res.validate()) + nested = mock.Mock() + nested.outputs = {'Blarg': {'Value': 'not-this', + 'error_msg': 'it is all bad'}} + nested.output.return_value = None + temp_res._nested = nested + self.assertRaises(exception.InvalidTemplateAttribute, + temp_res.FnGetAtt, 'Blarg') + def test_properties_normal(self): provider = { 'HeatTemplateFormatVersion': '2012-12-12', |