aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ice_validator/tests/test_base_template_names.py5
-rw-r--r--ice_validator/tests/test_files_in_flat_dir.py7
-rw-r--r--ice_validator/tests/test_neutron_port_fixed_ips_subnet.py51
3 files changed, 31 insertions, 32 deletions
diff --git a/ice_validator/tests/test_base_template_names.py b/ice_validator/tests/test_base_template_names.py
index 9bbf165..1159fb6 100644
--- a/ice_validator/tests/test_base_template_names.py
+++ b/ice_validator/tests/test_base_template_names.py
@@ -41,6 +41,8 @@ from os import listdir
from os import path
import re
+import pytest
+
from .helpers import check_basename_ending
from .helpers import validates
@@ -60,6 +62,9 @@ def test_base_template_names(template_dir):
and path.splitext(f)[-1] in [".yaml", ".yml"]
]
+ if not filenames and listdir(template_dir):
+ pytest.skip("Nested directory detected. Let that test fail instead.")
+
base_modules = []
for filename in filenames:
basename = path.splitext(filename)[0]
diff --git a/ice_validator/tests/test_files_in_flat_dir.py b/ice_validator/tests/test_files_in_flat_dir.py
index ac0ff7c..34732ba 100644
--- a/ice_validator/tests/test_files_in_flat_dir.py
+++ b/ice_validator/tests/test_files_in_flat_dir.py
@@ -44,7 +44,8 @@ def test_files_in_flat_dir(template_dir):
paths = (os.path.join(template_dir, p) for p in os.listdir(template_dir))
nested_dirs = (p for p in paths if os.path.isdir(p))
nested_dirs = [os.path.relpath(p, template_dir) for p in nested_dirs]
- msg = "Nested directories detected in template directory: {}".format(
- ", ".join(nested_dirs)
- )
+ msg = (
+ "Sub-directories are not allowed in a Heat package. The following "
+ "directories were detected: {}"
+ ).format(", ".join(nested_dirs))
assert not nested_dirs, msg
diff --git a/ice_validator/tests/test_neutron_port_fixed_ips_subnet.py b/ice_validator/tests/test_neutron_port_fixed_ips_subnet.py
index ccabf5e..8c15711 100644
--- a/ice_validator/tests/test_neutron_port_fixed_ips_subnet.py
+++ b/ice_validator/tests/test_neutron_port_fixed_ips_subnet.py
@@ -38,6 +38,8 @@
#
import re
+import pytest
+
from tests.utils.network_roles import get_network_type_from_port
from tests.structures import Heat
@@ -46,8 +48,6 @@ from tests.utils.nested_files import get_nested_files
from .utils.ports import check_parameter_format
from tests.structures import NeutronPortProcessor
-VERSION = "1.3.0"
-
RE_EXTERNAL_PARAM_SUBNET = re.compile( # match pattern
r"(?P<network_role>.+?)(_v6)?_subnet_id$"
)
@@ -75,41 +75,33 @@ fip_regx_dict = {
@validates("R-38236", "R-84123", "R-76160")
def test_internal_subnet_format(yaml_file):
- check_parameter_format(yaml_file, fip_regx_dict, "internal", NeutronPortProcessor, "fixed_ips", "subnet")
+ check_parameter_format(
+ yaml_file,
+ fip_regx_dict,
+ "internal",
+ NeutronPortProcessor,
+ "fixed_ips",
+ "subnet",
+ )
@validates("R-38236", "R-62802", "R-15287")
def test_external_subnet_format(yaml_file):
- check_parameter_format(yaml_file, fip_regx_dict, "external", NeutronPortProcessor, "fixed_ips", "subnet")
+ check_parameter_format(
+ yaml_file,
+ fip_regx_dict,
+ "external",
+ NeutronPortProcessor,
+ "fixed_ips",
+ "subnet",
+ )
@validates("R-84123", "R-76160")
def test_neutron_port_internal_fixed_ips_subnet_in_base(yaml_files):
- """
- Only check parent incremental modules, because nested file parameter
- name may have been changed.
-
- When
-
- * the VNF's Heat Orchestration Template's
- resource ``OS::Neutron::Port`` in an Incremental Module is attaching
- to an internal network
- that is created in the Base Module, AND
- * an IPv4 address is being cloud assigned by OpenStack's DHCP Service AND
- * the internal network IPv4 subnet is to be specified
- using the property ``fixed_ips`` map property ``subnet``/``subnet_id``,
-
- the parameter **MUST** follow the naming convention
-
- * ``int_{network-role}_subnet_id``
- an IPv6 address is being cloud assigned by OpenStack's DHCP Service AND
- * ``int_{network-role}_v6_subnet_id``
-
- Note that the parameter MUST be defined as an output parameter in
- the base module.
- """
-
base_path = get_base_template_from_yaml_files(yaml_files)
+ if not base_path:
+ pytest.skip("No base module detected")
base_heat = load_yaml(base_path)
base_outputs = base_heat.get("outputs") or {}
nested_template_paths = get_nested_files(yaml_files)
@@ -140,7 +132,8 @@ def test_neutron_port_internal_fixed_ips_subnet_in_base(yaml_files):
if param not in base_outputs:
errors.append(
(
- "Internal fixed_ips/subnet parameter {} is attached to port {}, but the subnet parameter "
+ "Internal fixed_ips/subnet parameter {} is attached to "
+ "port {}, but the subnet parameter "
"is not defined as an output in the base module ({})."
).format(param, r_id, base_path)
)