2 # ============LICENSE_START=======================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2018 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.
43 from .helpers import validates, get_environment_pair
46 @pytest.mark.heat_only
47 @validates('R-90279', 'R-01896', 'R-26124')
48 def test_no_unused_parameters_between_env_and_templates(heat_template):
50 Check all defined parameters are used in the appropiate Heat template.
52 environment_pair = get_environment_pair(heat_template)
53 if not environment_pair:
54 pytest.skip("No heat/env pair could be identified")
56 env_parameters = set(environment_pair["eyml"]["parameters"].keys())
57 template_parameters = set(environment_pair["yyml"]["parameters"].keys())
59 extra_in_template = template_parameters.difference(env_parameters)
60 extra_in_env = env_parameters.difference(template_parameters)
62 msg = "Mismatched parameters detected for the template and environment pair " \
63 "with basename ({basename}). "
65 msg += "The following parameters exist in the env file, but not the " \
66 "template: {extra_in_env}. "
68 msg += "The following parameters exist in the template file, but not the " \
69 "environment file: {extra_in_template}"
71 assert not (extra_in_template or extra_in_env), msg.format(
72 basename=os.path.split(environment_pair["name"])[-1],
73 extra_in_env=", ".join(extra_in_env),
74 extra_in_template=", ".join(extra_in_template)