aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests/test_nesting_level.py
diff options
context:
space:
mode:
authorLovett, Trevor <trevor.lovett@att.com>2020-01-16 15:47:59 -0600
committerLovett, Trevor <trevor.lovett@att.com>2020-01-16 15:47:59 -0600
commitded5c74ea07eb1541587de1042444fa6b590ddde (patch)
treef59f044962150b4f75d73f90e1ba59e4ff84c69d /ice_validator/tests/test_nesting_level.py
parent60d5bfeff163a2155679c9dbece42dc4e085bfd9 (diff)
[VVP] Resources not allowed in 2nd level templates
Cleaned up nesting detection logic Deleted test in Nova Server file as the nesting is no longer related to Nova servers Added check for resources in 2nd level nested files to existing test. Change-Id: I136efb786f67cf4c45fe4da3abaa3fcec024ba50 Issue-ID: VVP-357 Signed-off-by: Lovett, Trevor <trevor.lovett@att.com>
Diffstat (limited to 'ice_validator/tests/test_nesting_level.py')
-rw-r--r--ice_validator/tests/test_nesting_level.py45
1 files changed, 24 insertions, 21 deletions
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)