From 0ae7f108b91eea0a363236cb12bcb03c098d321d Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Fri, 20 Mar 2020 11:14:44 -0400 Subject: [PATCH] Use same flake8 extensions as Octavia Enabled the same flake8 extensions as the Octavia tree, fixing the bugs that they now caught. Trivialfix Change-Id: I0fc3f5e3a48dc9dc0286cf9b11847a77573ac411 --- .../v2/availability_zone_profile_client.py | 5 +++-- .../load_balancer/v2/flavor_profile_client.py | 4 ++-- .../v2/test_active_standby_iptables.py | 2 +- .../tests/barbican_scenario/v2/test_tls_barbican.py | 12 ++++++------ .../tests/scenario/v2/test_ipv6_traffic_ops.py | 2 +- .../tests/scenario/v2/test_pool.py | 2 +- tox.ini | 12 ++++++++---- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/octavia_tempest_plugin/services/load_balancer/v2/availability_zone_profile_client.py b/octavia_tempest_plugin/services/load_balancer/v2/availability_zone_profile_client.py index 631162d1..1aaab902 100644 --- a/octavia_tempest_plugin/services/load_balancer/v2/availability_zone_profile_client.py +++ b/octavia_tempest_plugin/services/load_balancer/v2/availability_zone_profile_client.py @@ -156,8 +156,9 @@ class AvailabilityZoneProfileClient(base_client.BaseLBaaSClient): return_object_only=return_object_only) def update_availability_zone_profile( - self, availability_zone_profile_id, name=Unset, provider_name=Unset, - availability_zone_data=Unset, return_object_only=True): + self, availability_zone_profile_id, name=Unset, + provider_name=Unset, availability_zone_data=Unset, + return_object_only=True): """Update an availability zone profile. :param availability_zone_profile_id: The availability zone profile ID diff --git a/octavia_tempest_plugin/services/load_balancer/v2/flavor_profile_client.py b/octavia_tempest_plugin/services/load_balancer/v2/flavor_profile_client.py index 7f359b22..811cff8d 100644 --- a/octavia_tempest_plugin/services/load_balancer/v2/flavor_profile_client.py +++ b/octavia_tempest_plugin/services/load_balancer/v2/flavor_profile_client.py @@ -145,8 +145,8 @@ class FlavorProfileClient(base_client.BaseLBaaSClient): return_object_only=return_object_only) def update_flavor_profile( - self, flavorprofile_id, name=Unset, provider_name=Unset, - flavor_data=Unset, return_object_only=True): + self, flavorprofile_id, name=Unset, provider_name=Unset, + flavor_data=Unset, return_object_only=True): """Update a flavor profile. :param flavorprofile_id: The flavor profile ID to update. diff --git a/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py b/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py index 2599beec..83f2d507 100644 --- a/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py +++ b/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py @@ -34,7 +34,7 @@ LOG = logging.getLogger(__name__) CONF.validation.run_validation, 'Active-Standby tests will not work without run_validation enabled.') class ActiveStandbyIptablesScenarioTest( - test_base.LoadBalancerBaseTestWithCompute): + test_base.LoadBalancerBaseTestWithCompute): @classmethod def skip_checks(cls): diff --git a/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py b/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py index 622731a6..84bfc20e 100644 --- a/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py +++ b/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py @@ -109,13 +109,13 @@ class TLSWithBarbicanTest(test_base.LoadBalancerBaseTestWithCompute): # Create a CA self-signed cert and key cls.ca_cert, ca_key = cert_utils.generate_ca_cert_and_key() - LOG.debug('CA Cert: %s' % cls.ca_cert.public_bytes( + LOG.debug('CA Cert: %s', cls.ca_cert.public_bytes( serialization.Encoding.PEM)) - LOG.debug('CA private Key: %s' % ca_key.private_bytes( + LOG.debug('CA private Key: %s', ca_key.private_bytes( encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.TraditionalOpenSSL, encryption_algorithm=serialization.NoEncryption())) - LOG.debug('CA public Key: %s' % ca_key.public_key().public_bytes( + LOG.debug('CA public Key: %s', ca_key.public_key().public_bytes( encoding=serialization.Encoding.PEM, format=serialization.PublicFormat.SubjectPublicKeyInfo)) @@ -127,7 +127,7 @@ class TLSWithBarbicanTest(test_base.LoadBalancerBaseTestWithCompute): # Create a server cert and key # This will be used as the "default certificate" in SNI tests. cls.server_uuid = uuidutils.generate_uuid() - LOG.debug('Server (default) UUID: %s' % cls.server_uuid) + LOG.debug('Server (default) UUID: %s', cls.server_uuid) server_cert, server_key, cls.server_secret_ref = ( cls._generate_load_certificate(cls.barbican_mgr, cls.ca_cert, @@ -135,7 +135,7 @@ class TLSWithBarbicanTest(test_base.LoadBalancerBaseTestWithCompute): # Create the SNI1 cert and key cls.SNI1_uuid = uuidutils.generate_uuid() - LOG.debug('SNI1 UUID: %s' % cls.SNI1_uuid) + LOG.debug('SNI1 UUID: %s', cls.SNI1_uuid) SNI1_cert, SNI1_key, cls.SNI1_secret_ref = ( cls._generate_load_certificate(cls.barbican_mgr, cls.ca_cert, @@ -143,7 +143,7 @@ class TLSWithBarbicanTest(test_base.LoadBalancerBaseTestWithCompute): # Create the SNI2 cert and key cls.SNI2_uuid = uuidutils.generate_uuid() - LOG.debug('SNI2 UUID: %s' % cls.SNI2_uuid) + LOG.debug('SNI2 UUID: %s', cls.SNI2_uuid) SNI2_cert, SNI2_key, cls.SNI2_secret_ref = ( cls._generate_load_certificate(cls.barbican_mgr, cls.ca_cert, diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py b/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py index a1dc6bb8..b37ab57f 100644 --- a/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py +++ b/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py @@ -24,7 +24,7 @@ CONF = config.CONF class IPv6TrafficOperationsScenarioTest( - test_base.LoadBalancerBaseTestWithCompute): + test_base.LoadBalancerBaseTestWithCompute): """Test traffic operations with an IPv6 VIP.""" @classmethod diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_pool.py b/octavia_tempest_plugin/tests/scenario/v2/test_pool.py index 31f01784..5e0622cb 100644 --- a/octavia_tempest_plugin/tests/scenario/v2/test_pool.py +++ b/octavia_tempest_plugin/tests/scenario/v2/test_pool.py @@ -171,7 +171,7 @@ class PoolScenarioTest(test_base.LoadBalancerBaseTest): const.LB_ALGORITHM_LEAST_CONNECTIONS if self.protocol == const.HTTP and ( - self.lb_feature_enabled.session_persistence_enabled): + self.lb_feature_enabled.session_persistence_enabled): pool_update_kwargs[const.SESSION_PERSISTENCE] = { const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE} pool = self.mem_pool_client.update_pool( diff --git a/tox.ini b/tox.ini index 33b941c1..4a61222e 100644 --- a/tox.ini +++ b/tox.ini @@ -17,7 +17,7 @@ commands = [testenv:pep8] basepython = python3 -commands = flake8 {posargs} +commands = flake8 [testenv:venv] basepython = python3 @@ -74,12 +74,16 @@ basepython = python3 commands = oslo_debug_helper {posargs} [flake8] -# E123, E125 skipped as they are invalid PEP-8. - show-source = True -ignore = E123,E125 builtins = _ exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build +import-order-style = pep8 +# [H106]: Don't put vim configuration in source files +# [H203]: Use assertIs(Not)None to check for None +# [H204]: Use assert(Not)Equal to check for equality +# [H205]: Use assert(Greater|Less)(Equal) for comparison +# [H904]: Delay string interpolations at logging calls +enable-extensions=H106,H203,H204,H205,H904 [testenv:genconfig] basepython = python3