diff options
author | Lovett, Trevor <trevor.lovett@att.com> | 2019-07-30 08:50:48 -0700 |
---|---|---|
committer | Lovett, Trevor (tl2972) <tl2972@att.com> | 2019-08-16 16:42:09 -0500 |
commit | 940ae7b0283191d590de40b71a9136bebc80e83c (patch) | |
tree | 8924052bded9411f87212969e1e51ee388e2be20 /ice_validator/tests/helpers.py | |
parent | 14c5243cbbb0652ee9ad99519d7d456f5a6c88f4 (diff) |
[VVP] Adding preload generation functionality
preload.py discovers and loads implementations of
AbstractPreloadGenerator from any module on sys.path prefixed with
preload_*
Initial support is provided for VNF-API and GR-API. The templates
will provide a guide for users to provide their values.
Known limitations:
- No support for Contrail. Preload will be created, but contrail
parameters will be skipped. This will be addressed in the future.
Issue-ID: VVP-227
Signed-off-by: stark, steven <steven.stark@att.com>
Change-Id: I081d50ac379062fbf1bffebd687e920220d32571
Signed-off-by: Lovett, Trevor <trevor.lovett@att.com>
Signed-off-by: Lovett, Trevor (tl2972) <tl2972@att.com>
Diffstat (limited to 'ice_validator/tests/helpers.py')
-rw-r--r-- | ice_validator/tests/helpers.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/ice_validator/tests/helpers.py b/ice_validator/tests/helpers.py index 6a6fb73..ff82c71 100644 --- a/ice_validator/tests/helpers.py +++ b/ice_validator/tests/helpers.py @@ -47,7 +47,16 @@ from collections import defaultdict from boltons import funcutils from tests import cached_yaml as yaml -VERSION = "1.1.0" +__path__ = [os.path.dirname(os.path.abspath(__file__))] +DEFAULT_OUTPUT_DIR = "{}/../output".format(__path__[0]) +RE_BASE = re.compile(r"(^base$)|(^base_)|(_base_)|(_base$)") + + +def is_base_module(template_path): + basename = os.path.basename(template_path).lower() + name, extension = os.path.splitext(basename) + is_yaml = extension in {".yml", ".yaml"} + return is_yaml and RE_BASE.search(name) and not name.endswith("_volume") def check_basename_ending(template_type, basename): @@ -262,9 +271,6 @@ def check_indices(pattern, values, value_type): return invalid_params -RE_BASE = re.compile(r"(^base$)|(^base_)|(_base_)|(_base$)") - - def get_base_template_from_yaml_files(yaml_files): """Return first filepath to match RE_BASE """ @@ -338,3 +344,15 @@ def get_param(property_value): else: return param return None + + +def get_output_dir(config): + """ + Retrieve the output directory for the reports and create it if necessary + :param config: pytest configuration + :return: output directory as string + """ + output_dir = config.option.output_dir or DEFAULT_OUTPUT_DIR + if not os.path.exists(output_dir): + os.makedirs(output_dir, exist_ok=True) + return output_dir |