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.
44 __path__ = [os.path.dirname(os.path.abspath(__file__))]
47 def pytest_addoption(parser):
49 Add needed CLI arguments
51 parser.addoption("--template-directory",
54 help="Directory which holds the templates for validation")
56 parser.addoption("--self-test",
59 help="Test the unit tests against their fixtured data")
62 def pytest_configure(config):
64 Ensure that we are receive either `--self-test` or
65 `--template-dir=<directory` as CLI arguments
67 if config.getoption('template_dir') and config.getoption('self_test'):
68 raise Exception(('"--template-dir", and "--self-test"'
69 ' are mutually exclusive'))
70 if not (config.getoption('template_dir') or config.getoption('self_test')):
71 raise Exception(('One of "--template-dir" or'
72 ' "--self-test" must be specified'))
75 def pytest_generate_tests(metafunc):
77 If a unit test requires an argument named 'filename'
78 we generate a test for the filenames selected. Either
79 the files contained in `template_dir` or if `template_dir`
80 is not specified on the CLI, the fixtures associated with this
83 if 'filename' in metafunc.fixturenames:
84 from .parametrizers import parametrize_filename
85 parametrize_filename(metafunc)
87 if 'filenames' in metafunc.fixturenames:
88 from .parametrizers import parametrize_filenames
89 parametrize_filenames(metafunc)
91 if 'template_dir' in metafunc.fixturenames:
92 from .parametrizers import parametrize_template_dir
93 parametrize_template_dir(metafunc)
95 if 'environment_pair' in metafunc.fixturenames:
96 from .parametrizers import parametrize_environment_pair
97 parametrize_environment_pair(metafunc)
99 if 'heat_volume_pair' in metafunc.fixturenames:
100 from .parametrizers import parametrize_heat_volume_pair
101 parametrize_heat_volume_pair(metafunc)
103 if 'yaml_files' in metafunc.fixturenames:
104 from .parametrizers import parametrize_yaml_files
105 parametrize_yaml_files(metafunc)
107 if 'env_files' in metafunc.fixturenames:
108 from .parametrizers import parametrize_environment_files
109 parametrize_environment_files(metafunc)
111 if 'yaml_file' in metafunc.fixturenames:
112 from .parametrizers import parametrize_yaml_file
113 parametrize_yaml_file(metafunc)
115 if 'env_file' in metafunc.fixturenames:
116 from .parametrizers import parametrize_environment_file
117 parametrize_environment_file(metafunc)
119 if 'parsed_yaml_file' in metafunc.fixturenames:
120 from .parametrizers import parametrize_parsed_yaml_file
121 parametrize_parsed_yaml_file(metafunc)
123 if 'parsed_environment_file' in metafunc.fixturenames:
124 from .parametrizers import parametrize_parsed_environment_file
125 parametrize_parsed_environment_file(metafunc)
127 if 'heat_template' in metafunc.fixturenames:
128 from .parametrizers import parametrize_heat_template
129 parametrize_heat_template(metafunc)
131 if 'heat_templates' in metafunc.fixturenames:
132 from .parametrizers import parametrize_heat_templates
133 parametrize_heat_templates(metafunc)
135 if 'volume_template' in metafunc.fixturenames:
136 from .parametrizers import parametrize_volume_template
137 parametrize_volume_template(metafunc)
139 if 'volume_templates' in metafunc.fixturenames:
140 from .parametrizers import parametrize_volume_templates
141 parametrize_volume_templates(metafunc)
143 if 'template' in metafunc.fixturenames:
144 from .parametrizers import parametrize_template
145 parametrize_template(metafunc)
147 if 'templates' in metafunc.fixturenames:
148 from .parametrizers import parametrize_templates
149 parametrize_templates(metafunc)