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.
41 """ environment file structure
47 from .helpers import validates
51 # pylint: disable=invalid-name
54 def test_environment_structure(env_file):
56 Check that all environments files only have the allowed sections
58 key_values = ["parameters", "event_sinks", "encrypted_parameters",
59 "parameter_merge_strategies"]
61 with open(env_file) as fh:
63 assert [k for k in key_values if k in yml], (
64 '%s missing any of %s' % (
70 def test_environment_file_contains_required_sections(env_file):
72 Check that all environments files only have the allowed sections
74 required_keys = ["parameters"]
76 with open(env_file) as fh:
78 missing_keys = [v for v in required_keys if v not in yml]
79 assert not missing_keys, '%s missing %s' % (env_file, missing_keys)
82 def test_environment_file_sections_have_the_right_format(env_file):
84 Check that all environment files have sections of the right format.
85 Do note that it only tests for dicts or not dicts currently.
89 "encrypted_parameters",
90 "parameter_merge_strategies"]
94 with open(env_file) as fh:
97 if not [k for k in dict_keys + not_dict_keys if k in yml]:
98 pytest.skip('The fixture is not applicable for this test')
100 bad_dict_keys = [k for k in dict_keys
102 and not isinstance(yml[k], dict)]
103 bad_not_dict_keys = [k for k in not_dict_keys
105 and isinstance(yml[k], dict)]
108 errors.append('must be dict %s' % bad_dict_keys)
109 if bad_not_dict_keys:
110 errors.append('must not be dict %s' % bad_not_dict_keys)
111 assert not errors, '%s errors:\n %s' % (