X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fhelpers.py;h=ec14bc048409838be0ab29649a8f27059a710e42;hb=2f606eaf4e4e02642e663dfee855d26d0bb17e41;hp=424dde15e7b99d98425daf3b0e1170d3cf203013;hpb=48d35093a120d5a8c02a28c4a72f4f7d69b664f4;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/helpers.py b/ice_validator/tests/helpers.py index 424dde1..ec14bc0 100644 --- a/ice_validator/tests/helpers.py +++ b/ice_validator/tests/helpers.py @@ -53,6 +53,23 @@ __path__ = [os.path.dirname(os.path.abspath(__file__))] DEFAULT_OUTPUT_DIR = "{}/../output".format(__path__[0]) RE_BASE = re.compile(r"(^base$)|(^base_)|(_base_)|(_base$)") +INTRINSIC_FUNCTIONS = [ + "get_resource", + "get_attr", + "str_replace", + "get_param", + "list_join", + "get_file", + "resource_facade", + "Fn::Select", + "repeat", + "digest", + "str_split", + "yaql", + "map_replace", + "map_merge", +] + def is_base_module(template_path): basename = os.path.basename(template_path).lower() @@ -238,6 +255,9 @@ def traverse(data, search_key, func, path=None): traverse(value, search_key, func, curr_path) elif value == search_key: func(curr_path, value) + elif search_key == data: + curr_path = path + [data] + func(curr_path, data) def check_indices(pattern, values, value_type): @@ -321,12 +341,13 @@ def parameter_type_to_heat_type(parameter): def prop_iterator(resource, *props): - terminators = ["get_resource", "get_attr", "str_replace", "get_param"] if "properties" in resource: resource = resource.get("properties") props = list(props) - if isinstance(resource, dict) and any(x for x in terminators if x in resource): + if isinstance(resource, dict) and any( + x for x in INTRINSIC_FUNCTIONS if x in resource + ): yield resource else: prop = resource.get(props.pop(0)) @@ -426,5 +447,9 @@ def is_nova_server(resource): """ checks resource is a nova server """ - return isinstance(resource, dict) and "type" in resource and "properties" in resource and resource.get("type") == "OS::Nova::Server" - + return ( + isinstance(resource, dict) + and "type" in resource + and "properties" in resource + and resource.get("type") == "OS::Nova::Server" + )