aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator
diff options
context:
space:
mode:
authorLovett, Trevor <trevor.lovett@att.com>2019-09-06 15:34:12 -0500
committerLovett, Trevor (tl2972) <tl2972@att.com>2019-09-06 15:42:13 -0500
commit1bc097aa957e560147b4d9af49d25e69a6692702 (patch)
treeebf426e45ecaa94ceaf378922731b243fd9ef1e6 /ice_validator
parent39119b4e131155ae38f7b435fc9f3693ca924eed (diff)
Enforce black code format via pre-commit hook
Issue-ID: VVP-203 Change-Id: If0de5b4bc1be0c9514decea1f4ff6f5ec79dc41b Signed-off-by: Lovett, Trevor <trevor.lovett@att.com>
Diffstat (limited to 'ice_validator')
-rw-r--r--ice_validator/app_tests/preload_tests/test_grapi.py3
-rw-r--r--ice_validator/preload/environment.py1
-rw-r--r--ice_validator/preload/generator.py2
-rw-r--r--ice_validator/preload_vnfapi/vnfapi_generator.py4
-rw-r--r--ice_validator/tests/conftest.py4
-rw-r--r--ice_validator/tests/helpers.py5
-rw-r--r--ice_validator/tests/structures.py15
-rw-r--r--ice_validator/tests/test_contrail_instance_ip_parameters.py50
-rw-r--r--ice_validator/tests/test_contrail_resource_id.py4
-rw-r--r--ice_validator/tests/test_environment_file_parameters.py5
-rw-r--r--ice_validator/tests/test_fixed_ips_include_vm_type_network_role.py18
-rw-r--r--ice_validator/tests/test_nested_parameters.py29
-rw-r--r--ice_validator/tests/test_non_server_name.py4
-rw-r--r--ice_validator/tests/utils/vm_types.py6
14 files changed, 111 insertions, 39 deletions
diff --git a/ice_validator/app_tests/preload_tests/test_grapi.py b/ice_validator/app_tests/preload_tests/test_grapi.py
index eea1a67..7f2361f 100644
--- a/ice_validator/app_tests/preload_tests/test_grapi.py
+++ b/ice_validator/app_tests/preload_tests/test_grapi.py
@@ -247,5 +247,6 @@ def test_preload_env_population_missing_value(preload):
base_path = THIS_DIR / "sample_env/preloads/grapi/base_incomplete.json"
data = load_json(base_path)
vnf_name = data["input"]["preload-vf-module-topology-information"][
- "vnf-topology-identifier-structure"]["vnf-name"]
+ "vnf-topology-identifier-structure"
+ ]["vnf-name"]
assert vnf_name == "VALUE FOR: vnf_name"
diff --git a/ice_validator/preload/environment.py b/ice_validator/preload/environment.py
index 5d69a99..3570dc5 100644
--- a/ice_validator/preload/environment.py
+++ b/ice_validator/preload/environment.py
@@ -175,7 +175,6 @@ class CloudServiceArchive:
class PreloadEnvironment:
-
def __init__(self, env_dir, parent=None):
self.base_dir = Path(env_dir)
self.parent = parent
diff --git a/ice_validator/preload/generator.py b/ice_validator/preload/generator.py
index 456174a..6c0d4b8 100644
--- a/ice_validator/preload/generator.py
+++ b/ice_validator/preload/generator.py
@@ -52,7 +52,7 @@ def represent_ordered_dict(dumper, data):
value.append((node_key, node_value))
- return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', value)
+ return yaml.nodes.MappingNode(u"tag:yaml.org,2002:map", value)
def get_json_template(template_dir, template_name):
diff --git a/ice_validator/preload_vnfapi/vnfapi_generator.py b/ice_validator/preload_vnfapi/vnfapi_generator.py
index dce1789..87a8408 100644
--- a/ice_validator/preload_vnfapi/vnfapi_generator.py
+++ b/ice_validator/preload_vnfapi/vnfapi_generator.py
@@ -89,7 +89,9 @@ class VnfApiPreloadGenerator(AbstractPreloadGenerator):
self._add_parameters(preload, vnf_module)
def _add_vnf_metadata(self, preload):
- vnf_meta = preload["input"]["vnf-topology-information"]["vnf-topology-identifier"]
+ vnf_meta = preload["input"]["vnf-topology-information"][
+ "vnf-topology-identifier"
+ ]
vnf_meta["vnf-name"] = self.replace("vnf_name")
vnf_meta["generic-vnf-type"] = self.replace(
"vnf-type",
diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py
index 9868067..ecaf662 100644
--- a/ice_validator/tests/conftest.py
+++ b/ice_validator/tests/conftest.py
@@ -833,7 +833,7 @@ def pytest_addoption(parser):
"--env-directory",
dest="env_dir",
action="store",
- help="optional directory of .env files for preload generation"
+ help="optional directory of .env files for preload generation",
)
parser.addoption(
@@ -843,7 +843,7 @@ def pytest_addoption(parser):
help=(
"Preload format to create (multiple allowed). If not provided "
"then all available formats will be created: {}"
- ).format(", ".join(get_generator_plugin_names()))
+ ).format(", ".join(get_generator_plugin_names())),
)
diff --git a/ice_validator/tests/helpers.py b/ice_validator/tests/helpers.py
index fefa8de..6266f08 100644
--- a/ice_validator/tests/helpers.py
+++ b/ice_validator/tests/helpers.py
@@ -393,7 +393,10 @@ def unzip(zip_path, target_dir):
:param zip_path: path to valid zip file
:param target_dir: directory to unzip zip_path
"""
- check(zipfile.is_zipfile(zip_path), "{} is not a valid zipfile or does not exist".format(zip_path))
+ check(
+ zipfile.is_zipfile(zip_path),
+ "{} is not a valid zipfile or does not exist".format(zip_path),
+ )
archive = zipfile.ZipFile(zip_path)
if not os.path.exists(target_dir):
os.makedirs(target_dir, exist_ok=True)
diff --git a/ice_validator/tests/structures.py b/ice_validator/tests/structures.py
index 12bfc63..0223bc3 100644
--- a/ice_validator/tests/structures.py
+++ b/ice_validator/tests/structures.py
@@ -495,7 +495,10 @@ class NeutronPortProcessor(HeatProcessor):
An OS::Nova:Port with the property binding:vnic_type
"""
resource_properties = nested_dict.get(resource, "properties", default={})
- if nested_dict.get(resource, "type") == cls.resource_type and resource_properties.get("binding:vnic_type", "") == "direct":
+ if (
+ nested_dict.get(resource, "type") == cls.resource_type
+ and resource_properties.get("binding:vnic_type", "") == "direct"
+ ):
return True
return False
@@ -785,10 +788,12 @@ class Resource(object):
try:
return int(count_value)
except (ValueError, TypeError):
- print((
- "WARNING: Invalid value for count parameter {}. Expected "
- "an integer, but got {}. Defaulting to 1"
- ).format(count_param, count_value))
+ print(
+ (
+ "WARNING: Invalid value for count parameter {}. Expected "
+ "an integer, but got {}. Defaulting to 1"
+ ).format(count_param, count_value)
+ )
return 1
@property
diff --git a/ice_validator/tests/test_contrail_instance_ip_parameters.py b/ice_validator/tests/test_contrail_instance_ip_parameters.py
index 312c8e9..4071f66 100644
--- a/ice_validator/tests/test_contrail_instance_ip_parameters.py
+++ b/ice_validator/tests/test_contrail_instance_ip_parameters.py
@@ -100,13 +100,13 @@ sid_regx_dict = {
"string": {
"readable": "{network-role}_subnet_id or {network-role}_v6_subnet_id",
"machine": RE_EXTERNAL_PARAM_SID,
- },
+ }
},
"internal": {
"string": {
"readable": "int_{network-role}_subnet_id or int_{network-role}_v6_subnet_id",
"machine": RE_INTERNAL_PARAM_SID,
- },
+ }
},
"parameter_to_resource_comparisons": ["network_role"],
}
@@ -114,22 +114,46 @@ sid_regx_dict = {
@validates("R-100000", "R-100010", "R-100030", "R-100050", "R-100070")
def test_contrail_external_instance_ip_address_parameter(yaml_file):
- check_parameter_format(yaml_file, iip_regx_dict, "external", ContrailV2InstanceIpProcessor, "instance_ip_address")
+ check_parameter_format(
+ yaml_file,
+ iip_regx_dict,
+ "external",
+ ContrailV2InstanceIpProcessor,
+ "instance_ip_address",
+ )
@validates("R-100000", "R-100090", "R-100110", "R-100130", "R-100150")
def test_contrail_internal_instance_ip_address_parameter(yaml_file):
- check_parameter_format(yaml_file, iip_regx_dict, "internal", ContrailV2InstanceIpProcessor, "instance_ip_address")
+ check_parameter_format(
+ yaml_file,
+ iip_regx_dict,
+ "internal",
+ ContrailV2InstanceIpProcessor,
+ "instance_ip_address",
+ )
@validates("R-100190", "R-100200", "R-100220")
def test_contrail_external_instance_subnet_id_parameter(yaml_file):
- check_parameter_format(yaml_file, sid_regx_dict, "external", ContrailV2InstanceIpProcessor, "subnet_uuid")
+ check_parameter_format(
+ yaml_file,
+ sid_regx_dict,
+ "external",
+ ContrailV2InstanceIpProcessor,
+ "subnet_uuid",
+ )
@validates("R-100190", "R-100240", "R-100260")
def test_contrail_internal_instance_subnet_id_parameter(yaml_file):
- check_parameter_format(yaml_file, sid_regx_dict, "internal", ContrailV2InstanceIpProcessor, "subnet_uuid")
+ check_parameter_format(
+ yaml_file,
+ sid_regx_dict,
+ "internal",
+ ContrailV2InstanceIpProcessor,
+ "subnet_uuid",
+ )
@validates("R-100240", "R-100260")
@@ -150,10 +174,12 @@ def test_contrail_incremental_module_internal_subnet_usage(yaml_files):
if not subnet_param:
continue
if subnet_param not in base_outputs:
- errors.append((
- "Resource ({}) is designated as an internal IP, but its "
- "subnet_uuid parameter ({}) does not refer to subnet in "
- "this template nor is it defined in the output section "
- "of the base module ({})"
- ).format(r_id, subnet_param, os.path.basename(base_path)))
+ errors.append(
+ (
+ "Resource ({}) is designated as an internal IP, but its "
+ "subnet_uuid parameter ({}) does not refer to subnet in "
+ "this template nor is it defined in the output section "
+ "of the base module ({})"
+ ).format(r_id, subnet_param, os.path.basename(base_path))
+ )
assert not errors, ". ".join(errors)
diff --git a/ice_validator/tests/test_contrail_resource_id.py b/ice_validator/tests/test_contrail_resource_id.py
index 06b41b4..dbbedbb 100644
--- a/ice_validator/tests/test_contrail_resource_id.py
+++ b/ice_validator/tests/test_contrail_resource_id.py
@@ -139,9 +139,7 @@ def test_contrail_servicehealthcheck_resource_id(yaml_file):
**MUST**
contain the ``{vm-type}``.
"""
- run_test(
- yaml_file, ContrailV2ServiceHealthCheckProcessor, get_vm_types, "vm_type"
- )
+ run_test(yaml_file, ContrailV2ServiceHealthCheckProcessor, get_vm_types, "vm_type")
@validates("R-16437")
diff --git a/ice_validator/tests/test_environment_file_parameters.py b/ice_validator/tests/test_environment_file_parameters.py
index 69485bc..9744b49 100644
--- a/ice_validator/tests/test_environment_file_parameters.py
+++ b/ice_validator/tests/test_environment_file_parameters.py
@@ -234,8 +234,9 @@ def get_preload_excluded_parameters(yaml_file, persistent_only=False, env_spec=N
for spec in specs:
if persistent_only and not spec.get("persistent"):
continue
- results.extend(get_template_parameters(yaml_file, resource_type,
- spec, all_resources))
+ results.extend(
+ get_template_parameters(yaml_file, resource_type, spec, all_resources)
+ )
return {item["param"] for item in results}
diff --git a/ice_validator/tests/test_fixed_ips_include_vm_type_network_role.py b/ice_validator/tests/test_fixed_ips_include_vm_type_network_role.py
index 2ce1bcf..feb48e5 100644
--- a/ice_validator/tests/test_fixed_ips_include_vm_type_network_role.py
+++ b/ice_validator/tests/test_fixed_ips_include_vm_type_network_role.py
@@ -87,9 +87,23 @@ fip_regx_dict = {
@validates("R-40971", "R-35735", "R-23503", "R-71577", "R-04697", "R-34037")
def test_external_fip_format(yaml_file):
- check_parameter_format(yaml_file, fip_regx_dict, "external", NeutronPortProcessor, "fixed_ips", "ip_address")
+ check_parameter_format(
+ yaml_file,
+ fip_regx_dict,
+ "external",
+ NeutronPortProcessor,
+ "fixed_ips",
+ "ip_address",
+ )
@validates("R-27818", "R-29765", "R-85235", "R-78380", "R-34037")
def test_internal_fip_format(yaml_file):
- check_parameter_format(yaml_file, fip_regx_dict, "internal", NeutronPortProcessor, "fixed_ips", "ip_address")
+ check_parameter_format(
+ yaml_file,
+ fip_regx_dict,
+ "internal",
+ NeutronPortProcessor,
+ "fixed_ips",
+ "ip_address",
+ )
diff --git a/ice_validator/tests/test_nested_parameters.py b/ice_validator/tests/test_nested_parameters.py
index 47c4d90..97d2f76 100644
--- a/ice_validator/tests/test_nested_parameters.py
+++ b/ice_validator/tests/test_nested_parameters.py
@@ -81,7 +81,12 @@ def check_nested_parameter_doesnt_change(yaml_file, nresource_type, *nprops):
r = Resource(resource_id=resource_id, resource=resource)
properties = r.get_nested_properties()
resources = r.get_nested_yaml(base_dir).get("resources", {})
- for nrid, nresource_dict in resources.items(): # iterate through nested file until found target r type
+ for (
+ nrid,
+ nresource_dict,
+ ) in (
+ resources.items()
+ ): # iterate through nested file until found target r type
if (
nresource_dict.get("type")
@@ -89,10 +94,19 @@ def check_nested_parameter_doesnt_change(yaml_file, nresource_type, *nprops):
):
continue
- for nparam in prop_iterator(nresource_dict, *nprops): # get iterator of all target parameters
- if nparam and "get_param" in nparam: # iterator yields None if parameter isn't found
+ for nparam in prop_iterator(
+ nresource_dict, *nprops
+ ): # get iterator of all target parameters
+ if (
+ nparam and "get_param" in nparam
+ ): # iterator yields None if parameter isn't found
nparam = nparam.get("get_param")
- for k1, v1 in properties.items(): # found nparam, now comparing to parent template
+ for (
+ k1,
+ v1,
+ ) in (
+ properties.items()
+ ): # found nparam, now comparing to parent template
if isinstance(v1, dict) and "get_param" in v1:
parameter = v1.get("get_param")
# k1: nested resource parameter definition
@@ -105,7 +119,9 @@ def check_nested_parameter_doesnt_change(yaml_file, nresource_type, *nprops):
if isinstance(parameter, list):
parameter = parameter[0]
- if k1 != nparam: # we only care about the parameter we found in nested template
+ if (
+ k1 != nparam
+ ): # we only care about the parameter we found in nested template
continue
if k1 != parameter:
@@ -129,6 +145,7 @@ def check_nested_parameter_doesnt_change(yaml_file, nresource_type, *nprops):
# def test_parameter_name_doesnt_change_in_nested_template(yaml_file):
# check_nested_parameter_doesnt_change(yaml_file)
+
@validates("R-708564")
def test_server_name_parameter_name_doesnt_change_in_nested_template(heat_template):
check_nested_parameter_doesnt_change(heat_template, "OS::Nova::Server", "name")
@@ -257,7 +274,7 @@ def test_vmi_aap_parameter_name_doesnt_change_in_nested_template(heat_template):
"virtual_machine_interface_allowed_address_pairs",
"virtual_machine_interface_allowed_address_pairs_allowed_address_pair",
"virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip",
- "virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix"
+ "virtual_machine_interface_allowed_address_pairs_allowed_address_pair_ip_ip_prefix",
)
diff --git a/ice_validator/tests/test_non_server_name.py b/ice_validator/tests/test_non_server_name.py
index 7139c9b..9361389 100644
--- a/ice_validator/tests/test_non_server_name.py
+++ b/ice_validator/tests/test_non_server_name.py
@@ -151,7 +151,9 @@ def test_non_server_name(yaml_file):
def test_non_server_name_unique(heat_template):
"""Test name has unique value
"""
- list_nest = nested_files.get_list_of_nested_files(heat_template, os.path.dirname(heat_template))
+ list_nest = nested_files.get_list_of_nested_files(
+ heat_template, os.path.dirname(heat_template)
+ )
list_nest.append(heat_template)
non_servers = {}
for yaml_file in list_nest:
diff --git a/ice_validator/tests/utils/vm_types.py b/ice_validator/tests/utils/vm_types.py
index ae14336..ae6d7ff 100644
--- a/ice_validator/tests/utils/vm_types.py
+++ b/ice_validator/tests/utils/vm_types.py
@@ -83,7 +83,11 @@ def get_vm_types_for_resource(resource):
def is_nova_server(resource):
- return "type" in resource and "properties" in resource and resource.get("type") == "OS::Nova::Server"
+ return (
+ "type" in resource
+ and "properties" in resource
+ and resource.get("type") == "OS::Nova::Server"
+ )
def get_vm_type_for_nova_server(resource):