[VVP] Add test for R-100260 and fix mapping
[vvp/validation-scripts.git] / ice_validator / tests / parametrizers.py
index 511c39a..35cf6e0 100644 (file)
@@ -35,7 +35,6 @@
 #
 # ============LICENSE_END============================================
 #
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 """parametrizers
 
 from os import path, listdir
 import re
-import yaml
+from tests import cached_yaml as yaml
 import pytest
-from .helpers import get_parsed_yml_for_yaml_files, check_basename_ending
-from .utils.nested_files import get_list_of_nested_files
+from tests.helpers import get_parsed_yml_for_yaml_files, check_basename_ending
+from tests.utils.nested_files import get_nested_files
 
 VERSION = "1.0.0"
 
-
 # pylint: disable=invalid-name
 
 
@@ -62,7 +60,7 @@ def get_template_dir(metafunc):
     """
     if metafunc.config.getoption("template_dir") is None:
         return path.join(
-            path.dirname(path.realpath(__file__)),
+            path.dirname(metafunc.module.__file__),
             "fixtures",
             metafunc.function.__module__.split(".")[-1],
         )
@@ -70,28 +68,8 @@ def get_template_dir(metafunc):
         return metafunc.config.getoption("template_dir")[0]
 
 
-def get_nested_files(filenames):
-    """
-    returns all the nested files for a set of filenames
-    """
-    nested_files = []
-    for filename in filenames:
-        try:
-            with open(filename) as fh:
-                yml = yaml.load(fh)
-            if "resources" not in yml:
-                continue
-            nested_files.extend(
-                get_list_of_nested_files(yml["resources"], path.dirname(filename))
-            )
-        except yaml.YAMLError as e:
-            print(e)  # pylint: disable=superfluous-parens
-            continue
-    return nested_files
-
-
 def list_filenames_in_template_dir(
-        metafunc, extensions, template_type="", sub_dirs=None
+    metafunc, extensions, template_type="", sub_dirs=None
 ):
     """
     returns the filenames in a template_dir, either as its passed in
@@ -106,23 +84,23 @@ def list_filenames_in_template_dir(
             path.join(template_dir, s, f)
             for s in sub_dirs
             for f in listdir(path.join(template_dir, s))
-            if (path.isfile(path.join(template_dir, s, f)) and
-                path.splitext(f)[-1] in extensions and
-                check_basename_ending(template_type, path.splitext(f)[0]))
+            if path.isfile(path.join(template_dir, s, f))
+            and path.splitext(f)[-1] in extensions
+            and check_basename_ending(template_type, path.splitext(f)[0])
         ]
     else:
         filenames = [
             path.join(template_dir, f)
             for f in listdir(template_dir)
-            if (path.isfile(path.join(template_dir, f)) and
-                path.splitext(f)[-1] in extensions and
-                check_basename_ending(template_type, path.splitext(f)[0]))
+            if path.isfile(path.join(template_dir, f))
+            and path.splitext(f)[-1] in extensions
+            and check_basename_ending(template_type, path.splitext(f)[0])
         ]
     return filenames
 
 
 def list_template_dir(
-        metafunc, extensions, exclude_nested=True, template_type="", sub_dirs=None
+    metafunc, extensions, exclude_nested=True, template_type="", sub_dirs=None
 ):
     """
     returns the filenames excluding the nested files for a template_dir,
@@ -141,7 +119,7 @@ def list_template_dir(
 
 
 def get_filenames_list(
-        metafunc, extensions=None, exclude_nested=False, template_type=""
+    metafunc, extensions=None, exclude_nested=False, template_type=""
 ):
     """
     returns the filename fixtures for the template dir, either as by how its
@@ -168,7 +146,7 @@ def get_filenames_list(
 
 
 def get_filenames_lists(
-        metafunc, extensions=None, exclude_nested=False, template_type=""
+    metafunc, extensions=None, exclude_nested=False, template_type=""
 ):
     """
     returns the list of files in the template dir, either as by how its
@@ -199,7 +177,7 @@ def get_filenames_lists(
 
 
 def get_parsed_yaml_files(
-        metafunc, extensions, exclude_nested=True, template_type="", sections=None
+    metafunc, extensions, exclude_nested=True, template_type="", sections=None
 ):
     """
     returns the list of parsed yaml files in the specified template dir,