From 4c2a2033d927552f7e9281e516afba38f146c242 Mon Sep 17 00:00:00 2001 From: "Lovett, Trevor" Date: Thu, 6 Aug 2020 15:33:13 -0500 Subject: [PATCH] Aligned test with updated R-610030 An incremental module must have a server or volume Change-Id: I579f7303cbeb2785fbb3e1e85b10af77433292fa Issue-ID: VVP-451 Signed-off-by: Lovett, Trevor --- ice_validator/app_tests/preload_tests/test_environment.py | 7 ++----- ice_validator/preload/environment.py | 4 +--- ice_validator/tests/test_incremental_module.py | 8 ++++++-- ice_validator/tests/test_nested_template_parameters.py | 3 +-- ice_validator/tests/test_port_resource_ids.py | 5 ++++- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ice_validator/app_tests/preload_tests/test_environment.py b/ice_validator/app_tests/preload_tests/test_environment.py index dacbd37..1c965a0 100644 --- a/ice_validator/app_tests/preload_tests/test_environment.py +++ b/ice_validator/app_tests/preload_tests/test_environment.py @@ -65,10 +65,7 @@ def test_csar_str_and_repr(csar): def test_csar_vf_module_model_name(csar): - assert ( - csar.get_vf_module_model_name("vdns") - == "Stark0917VlbVf..vdns..module-3" - ) + assert csar.get_vf_module_model_name("vdns") == "Stark0917VlbVf..vdns..module-3" def test_csar_get_vf_module_resource_name(csar): @@ -177,7 +174,7 @@ def test_preload_environment_defaults_in_module_env(env): "custom_env_3": "default", "my_ip": "default", "vf-module-model-name": "Starkmultimodule2A9463fd82915..base..module-0", - "vnf-type": "StarkMultiModule2_43550/StarkMultiModule2 a9463fd8-2915 0" + "vnf-type": "StarkMultiModule2_43550/StarkMultiModule2 a9463fd8-2915 0", } mod = env.get_environment("env_one").get_module("base") assert mod == { diff --git a/ice_validator/preload/environment.py b/ice_validator/preload/environment.py index 6d8d7c3..120e3c8 100644 --- a/ice_validator/preload/environment.py +++ b/ice_validator/preload/environment.py @@ -51,7 +51,7 @@ class CloudServiceArchive: :param vf_module: name of Heat module (no path or file extension) :return: The definition of the module as a dict or None if not found """ - if( + if ( vf_module.endswith(".env") or vf_module.endswith(".yaml") or vf_module.endswith(".yml") @@ -293,7 +293,6 @@ class PreloadEnvironment: class EnvironmentFilePreloadInstance(AbstractPreloadInstance): - def __init__(self, env: PreloadEnvironment, module_label: str, module_params: dict): self.module_params = module_params self._module_label = module_label @@ -397,7 +396,6 @@ class EnvironmentFilePreloadInstance(AbstractPreloadInstance): class EnvironmentFileDataSource(AbstractPreloadDataSource): - def __init__(self, path: Path): super().__init__(path) check(path.is_dir(), f"{path} must be an existing directory") diff --git a/ice_validator/tests/test_incremental_module.py b/ice_validator/tests/test_incremental_module.py index 606dfe4..47c7901 100644 --- a/ice_validator/tests/test_incremental_module.py +++ b/ice_validator/tests/test_incremental_module.py @@ -50,10 +50,14 @@ def test_incremental_module_has_server(yaml_files): servers = Heat(filepath=module).get_resource_by_type( "OS::Nova::Server", all_resources=True ) - if not servers: + volumes = Heat(filepath=module).get_resource_by_type( + "OS::Cinder::Volume", all_resources=True + ) + if not (servers or volumes): errors.append(os.path.basename(module)) assert not errors, ( - "The following incremental modules do not contain an OS::Nova::Server " + "The following incremental modules do not contain at least one " + "OS::Nova::Server or OS::Cinder::Volume " "as required: {}".format(", ".join(errors)) ) diff --git a/ice_validator/tests/test_nested_template_parameters.py b/ice_validator/tests/test_nested_template_parameters.py index 016ebc9..66d8adc 100644 --- a/ice_validator/tests/test_nested_template_parameters.py +++ b/ice_validator/tests/test_nested_template_parameters.py @@ -72,8 +72,7 @@ def validate_parms(dirname, basename, nested, nested_props, prop_type): if additional: bad.append( "%s properties %s not defined as " - "parameters in %s" - % (rid, list(additional), nested_filepath) + "parameters in %s" % (rid, list(additional), nested_filepath) ) return bad diff --git a/ice_validator/tests/test_port_resource_ids.py b/ice_validator/tests/test_port_resource_ids.py index be74349..1648300 100644 --- a/ice_validator/tests/test_port_resource_ids.py +++ b/ice_validator/tests/test_port_resource_ids.py @@ -123,7 +123,10 @@ def test_port_resource_ids(yaml_file): network_type = get_network_type_from_port(port_resource) if not network_type: invalid_ports.append( - (port_id, "Unable to determine network type for port (internal or external).") + ( + port_id, + "Unable to determine network type for port (internal or external).", + ) ) continue -- 2.16.6