X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=blobdiff_plain;f=ice_validator%2Ftests%2Ftest_nesting_level.py;h=bb8c704c329c163674f80310a02f87977bbd7cd2;hp=6c31dbbb1a5854e0c1bf9d4f822ae9ea2b1bf7d0;hb=ded5c74ea07eb1541587de1042444fa6b590ddde;hpb=60d5bfeff163a2155679c9dbece42dc4e085bfd9 diff --git a/ice_validator/tests/test_nesting_level.py b/ice_validator/tests/test_nesting_level.py index 6c31dbb..bb8c704 100644 --- a/ice_validator/tests/test_nesting_level.py +++ b/ice_validator/tests/test_nesting_level.py @@ -34,30 +34,33 @@ # limitations under the License. # # ============LICENSE_END============================================ -# -# - -""" -test nesting level -0 -> 1 -> 2 -> too many levels. -""" +from .structures import Heat from .utils import nested_files from .helpers import validates -VERSION = "1.1.0" - -# pylint: disable=invalid-name - -@validates("R-60011") +@validates("R-60011", "R-17528") def test_nesting_level(yaml_files): - """ - A VNF's Heat Orchestration Template **MUST** have no more than two - levels of nesting. - """ - bad, __, __, __ = nested_files.get_nesting(yaml_files) - assert not bad, "nesting depth of %d exceeded: %s" % ( - nested_files.MAX_DEPTH, - ", ".join(bad), - ) + errors = set() + non_nested_files = [ + f for f in yaml_files if not nested_files.file_is_a_nested_template(f) + ] + heats = [Heat(f) for f in non_nested_files] + for heat in heats: + for depth, nested_heat in heat.iter_nested_heat(): + if depth >= 3: + errors.add( + ( + "{} is nested {} levels deep, but a maximum of {} levels are " + "supported." + ).format(nested_heat.basename, depth, nested_files.MAX_DEPTH) + ) + if depth == 2 and nested_heat.resources: + errors.add( + ( + "{} is a second level nested file, but it includes " + "resources. Remove all Heat resources from this file." + ).format(nested_heat.basename) + ) + assert not errors, "\n\n".join(errors)