2 # ============LICENSE_START====================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 # ===================================================================
8 # Unless otherwise specified, all software contained herein is licensed
9 # under the Apache License, Version 2.0 (the "License");
10 # you may not use this software except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
23 # Unless otherwise specified, all documentation contained herein is licensed
24 # under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 # you may not use this documentation except in compliance with the License.
26 # You may obtain a copy of the License at
28 # https://creativecommons.org/licenses/by/4.0/
30 # Unless required by applicable law or agreed to in writing, documentation
31 # distributed under the License is distributed on an "AS IS" BASIS,
32 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 # See the License for the specific language governing permissions and
34 # limitations under the License.
36 # ============LICENSE_END============================================
40 """Test heat template structure
44 from tests import cached_yaml as yaml
45 from .helpers import validates, is_base_module, load_yaml
49 # pylint: disable=invalid-name
53 def test_heat_template_structure_contains_heat_template_version(yaml_file):
55 Check that all heat templates have the required sections
57 template = load_yaml(yaml_file)
58 assert "heat_template_version" in template, "This template must contain a heat_template_version section"
62 def test_heat_template_structure_contains_description(yaml_file):
64 Check that all heat templates have the required sections
66 template = load_yaml(yaml_file)
67 assert "description" in template, "This template must contain a description section"
71 def test_heat_template_structure_contains_parameters(heat_template):
73 Check that all heat templates have the required sections
75 if is_base_module(heat_template):
76 pytest.skip("Not applicable to base modules")
77 template = load_yaml(heat_template)
78 assert "parameters" in template, "This template must contain a parameters section"
82 def test_heat_template_structure_contains_resources(heat_template):
84 Check that all heat templates have the required sections
86 if is_base_module(heat_template):
87 pytest.skip("Not applicable to base modules")
88 template = load_yaml(heat_template)
89 assert "resources" in template, "This template must contain a resources section"
93 def test_parameter_type(yaml_file):
94 """A VNF's Heat Orchestration Template's parameter type **MUST**
95 be one of the following values:
97 types = ["string", "number", "json", "comma_delimited_list", "boolean"]
98 with open(yaml_file) as fh:
100 for key, param in yml.get("parameters", {}).items():
101 assert isinstance(param, dict), "%s parameter %s is not dict" % (yaml_file, key)
102 if "type" not in param:
105 assert typ in types, '%s parameter %s has invalid type "%s"' % (