aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests/helpers.py
diff options
context:
space:
mode:
authorSteven Wright <sw3588@att.com>2019-08-20 17:22:38 +0000
committerGerrit Code Review <gerrit@onap.org>2019-08-20 17:22:38 +0000
commit2b57f73aad5c0a6755a7dfddc7e79937a74de00f (patch)
treef33c3e82a12964739ab9e325d968ef14a33741cf /ice_validator/tests/helpers.py
parent0907dd0dcd870afc12d4cb245d970fefff803898 (diff)
parent940ae7b0283191d590de40b71a9136bebc80e83c (diff)
Merge "[VVP] Adding preload generation functionality"
Diffstat (limited to 'ice_validator/tests/helpers.py')
-rw-r--r--ice_validator/tests/helpers.py26
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