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============================================
38 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
45 from tests import cached_yaml as yaml
46 from tests.structures import Resource
48 from .helpers import validates
53 def check_nested_parameter_doesnt_change(yaml_file, parameter):
55 with open(yaml_file) as fh:
58 # skip if resources are not defined
59 if "resources" not in yml:
60 pytest.skip("No resources specified in the heat template")
62 invalid_parameters = []
65 checking if property: { get_param: <parameter> }, then property == <parameter>
70 property: { get_param: <parameter> }
73 type: OS::Heat::ResourceGroup
77 property: { get_param: <parameter> }
79 for resource_id, resource in yml.get("resources", {}).items():
80 r = Resource(resource_id=resource_id, resource=resource)
81 properties = r.get_nested_properties()
82 for k1, v1 in properties.items():
86 and parameter == v1.get("get_param")
89 invalid_parameters.append(
91 "resource": r.resource_id,
92 "nested parameter": k1,
93 "parameter": parameter,
98 not invalid_parameters
99 ), "Invalid parameter name change detected in nested template {}".format(
104 @validates("R-70757")
105 def test_vm_role_doesnt_change_in_nested_template(yaml_file):
106 check_nested_parameter_doesnt_change(yaml_file, "vm_role")
109 @validates("R-44491")
110 def test_vnf_id_doesnt_change_in_nested_template(yaml_file):
111 check_nested_parameter_doesnt_change(yaml_file, "vnf_id")
114 @validates("R-86237")
115 def test_vf_module_id_doesnt_change_in_nested_template(yaml_file):
116 check_nested_parameter_doesnt_change(yaml_file, "vf_module_id")
119 @validates("R-16576")
120 def test_vnf_name_doesnt_change_in_nested_template(yaml_file):
121 check_nested_parameter_doesnt_change(yaml_file, "vnf_name")
124 @validates("R-49177")
125 def test_vf_module_name_doesnt_change_in_nested_template(yaml_file):
126 check_nested_parameter_doesnt_change(yaml_file, "vf_module_name")
129 @validates("R-22441")
130 def test_vf_module_index_name_doesnt_change_in_nested_template(yaml_file):
131 check_nested_parameter_doesnt_change(yaml_file, "vf_module_index")
134 @validates("R-62954")
135 def test_environment_context_name_doesnt_change_in_nested_template(yaml_file):
136 check_nested_parameter_doesnt_change(yaml_file, "environment_context")
139 @validates("R-75202")
140 def test_workload_context_name_doesnt_change_in_nested_template(yaml_file):
141 check_nested_parameter_doesnt_change(yaml_file, "workload_context")