diff options
author | Lovett, Trevor <trevor.lovett@att.com> | 2019-09-06 15:34:12 -0500 |
---|---|---|
committer | Lovett, Trevor (tl2972) <tl2972@att.com> | 2019-09-06 15:42:13 -0500 |
commit | 1bc097aa957e560147b4d9af49d25e69a6692702 (patch) | |
tree | ebf426e45ecaa94ceaf378922731b243fd9ef1e6 /ice_validator/tests | |
parent | 39119b4e131155ae38f7b435fc9f3693ca924eed (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/tests')
-rw-r--r-- | ice_validator/tests/conftest.py | 4 | ||||
-rw-r--r-- | ice_validator/tests/helpers.py | 5 | ||||
-rw-r--r-- | ice_validator/tests/structures.py | 15 | ||||
-rw-r--r-- | ice_validator/tests/test_contrail_instance_ip_parameters.py | 50 | ||||
-rw-r--r-- | ice_validator/tests/test_contrail_resource_id.py | 4 | ||||
-rw-r--r-- | ice_validator/tests/test_environment_file_parameters.py | 5 | ||||
-rw-r--r-- | ice_validator/tests/test_fixed_ips_include_vm_type_network_role.py | 18 | ||||
-rw-r--r-- | ice_validator/tests/test_nested_parameters.py | 29 | ||||
-rw-r--r-- | ice_validator/tests/test_non_server_name.py | 4 | ||||
-rw-r--r-- | ice_validator/tests/utils/vm_types.py | 6 |
10 files changed, 105 insertions, 35 deletions
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): |