aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests/helpers.py
diff options
context:
space:
mode:
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