From e03bea913ce6b9520b85dbdead7b497a5ed3df32 Mon Sep 17 00:00:00 2001 From: Ken'ichi Ohmichi Date: Thu, 19 Nov 2015 07:45:58 +0000 Subject: [PATCH] Fix H404/405 violations for api tests(2/3) There is a lot of H404/405 violations in Tempest now, and that leads difficult to migrate the code to tempest-lib or the other projects' repos. This patch fixes these violations for api tests of network. Change-Id: I50c59abe3fe40346602e2c07d9b0b1b20a3a471d --- .../network/admin/test_agent_management.py | 5 +- .../admin/test_external_network_extension.py | 5 +- .../admin/test_external_networks_negative.py | 8 +-- tempest/api/network/admin/test_quotas.py | 4 +- tempest/api/network/admin/test_routers_dvr.py | 11 ++-- tempest/api/network/base.py | 4 +- .../api/network/test_allowed_address_pair.py | 6 +- tempest/api/network/test_dhcp_ipv6.py | 64 ++++++++----------- tempest/api/network/test_extensions.py | 5 +- .../api/network/test_extra_dhcp_options.py | 4 +- tempest/api/network/test_floating_ips.py | 4 +- .../api/network/test_floating_ips_negative.py | 3 +- .../api/network/test_metering_extensions.py | 4 +- tempest/api/network/test_networks.py | 18 ++---- tempest/api/network/test_ports.py | 3 +- .../network/test_subnetpools_extensions.py | 4 +- 16 files changed, 59 insertions(+), 93 deletions(-) diff --git a/tempest/api/network/admin/test_agent_management.py b/tempest/api/network/admin/test_agent_management.py index 128398b761..c5d0d57b59 100644 --- a/tempest/api/network/admin/test_agent_management.py +++ b/tempest/api/network/admin/test_agent_management.py @@ -79,9 +79,8 @@ class AgentManagementTestJSON(base.BaseAdminNetworkTest): self.assertEqual(updated_description, description) def _restore_agent(self): - """ - Restore the agent description after update test. - """ + """Restore the agent description after update test""" + description = self.agent['description'] or '' origin_agent = {'description': description} self.admin_client.update_agent(agent_id=self.agent['id'], diff --git a/tempest/api/network/admin/test_external_network_extension.py b/tempest/api/network/admin/test_external_network_extension.py index ac5358743f..fce63ac56d 100644 --- a/tempest/api/network/admin/test_external_network_extension.py +++ b/tempest/api/network/admin/test_external_network_extension.py @@ -91,10 +91,9 @@ class ExternalNetworksTestJSON(base.BaseAdminNetworkTest): @test.idempotent_id('82068503-2cf2-4ed4-b3be-ecb89432e4bb') def test_delete_external_networks_with_floating_ip(self): - """Verifies external network can be deleted while still holding - (unassociated) floating IPs + # Verifies external network can be deleted while still holding + # (unassociated) floating IPs - """ # Set cls.client to admin to use base.create_subnet() client = self.admin_client body = self.admin_networks_client.create_network( diff --git a/tempest/api/network/admin/test_external_networks_negative.py b/tempest/api/network/admin/test_external_networks_negative.py index 8dfce248f2..1e1573e869 100644 --- a/tempest/api/network/admin/test_external_networks_negative.py +++ b/tempest/api/network/admin/test_external_networks_negative.py @@ -27,11 +27,9 @@ class ExternalNetworksAdminNegativeTestJSON(base.BaseAdminNetworkTest): @test.attr(type=['negative']) @test.idempotent_id('d402ae6c-0be0-4d8e-833b-a738895d98d0') def test_create_port_with_precreated_floatingip_as_fixed_ip(self): - """ - External networks can be used to create both floating-ip as well - as instance-ip. So, creating an instance-ip with a value of a - pre-created floating-ip should be denied. - """ + # NOTE: External networks can be used to create both floating-ip as + # well as instance-ip. So, creating an instance-ip with a value of a + # pre-created floating-ip should be denied. # create a floating ip client = self.admin_client diff --git a/tempest/api/network/admin/test_quotas.py b/tempest/api/network/admin/test_quotas.py index f5c57846a9..4a25206440 100644 --- a/tempest/api/network/admin/test_quotas.py +++ b/tempest/api/network/admin/test_quotas.py @@ -21,9 +21,7 @@ from tempest import test class QuotasTest(base.BaseAdminNetworkTest): - """ - Tests the following operations in the Neutron API using the REST client for - Neutron: + """Tests the following operations in the Neutron API: list quotas for tenants who have non-default quota values show quotas for a specified tenant diff --git a/tempest/api/network/admin/test_routers_dvr.py b/tempest/api/network/admin/test_routers_dvr.py index 365698d39c..3e787af933 100644 --- a/tempest/api/network/admin/test_routers_dvr.py +++ b/tempest/api/network/admin/test_routers_dvr.py @@ -42,7 +42,8 @@ class RoutersTestDVR(base.BaseRouterTest): @test.idempotent_id('08a2a0a8-f1e4-4b34-8e30-e522e836c44e') def test_distributed_router_creation(self): - """ + """Test distributed router creation + Test uses administrative credentials to creates a DVR (Distributed Virtual Routing) router using the distributed=True. @@ -59,7 +60,8 @@ class RoutersTestDVR(base.BaseRouterTest): @test.idempotent_id('8a0a72b4-7290-4677-afeb-b4ffe37bc352') def test_centralized_router_creation(self): - """ + """Test centralized router creation + Test uses administrative credentials to creates a CVR (Centralized Virtual Routing) router using the distributed=False. @@ -77,10 +79,11 @@ class RoutersTestDVR(base.BaseRouterTest): @test.idempotent_id('acd43596-c1fb-439d-ada8-31ad48ae3c2e') def test_centralized_router_update_to_dvr(self): - """ + """Test centralized router update + Test uses administrative credentials to creates a CVR (Centralized Virtual Routing) router using the - distributed=False.Then it will "update" the router + distributed=False. Then it will "update" the router distributed attribute to True Acceptance diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py index 5198ae8ba7..2c0b98119e 100644 --- a/tempest/api/network/base.py +++ b/tempest/api/network/base.py @@ -28,9 +28,7 @@ LOG = logging.getLogger(__name__) class BaseNetworkTest(tempest.test.BaseTestCase): - - """ - Base class for the Neutron tests that use the Tempest Neutron REST client + """Base class for the Neutron tests Per the Neutron API Guide, API v1.x was removed from the source code tree (docs.openstack.org/api/openstack-network/2.0/content/Overview-d1e71.html) diff --git a/tempest/api/network/test_allowed_address_pair.py b/tempest/api/network/test_allowed_address_pair.py index 41714aa9b8..394aec1543 100644 --- a/tempest/api/network/test_allowed_address_pair.py +++ b/tempest/api/network/test_allowed_address_pair.py @@ -23,9 +23,9 @@ CONF = config.CONF class AllowedAddressPairTestJSON(base.BaseNetworkTest): - """ - Tests the Neutron Allowed Address Pair API extension using the Tempest - ReST client. The following API operations are tested with this extension: + """Tests the Neutron Allowed Address Pair API extension + + The following API operations are tested with this extension: create port list ports diff --git a/tempest/api/network/test_dhcp_ipv6.py b/tempest/api/network/test_dhcp_ipv6.py index 27713a2ae8..ceb7906b02 100644 --- a/tempest/api/network/test_dhcp_ipv6.py +++ b/tempest/api/network/test_dhcp_ipv6.py @@ -99,10 +99,9 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('e5517e62-6f16-430d-a672-f80875493d4c') def test_dhcpv6_stateless_eui64(self): - """When subnets configured with RAs SLAAC (AOM=100) and DHCP stateless - (AOM=110) both for radvd and dnsmasq, port shall receive IP address - calculated from its MAC. - """ + # NOTE: When subnets configured with RAs SLAAC (AOM=100) and DHCP + # stateless (AOM=110) both for radvd and dnsmasq, port shall receive + # IP address calculated from its MAC. for ra_mode, add_mode in ( ('slaac', 'slaac'), ('dhcpv6-stateless', 'dhcpv6-stateless'), @@ -118,10 +117,9 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('ae2f4a5d-03ff-4c42-a3b0-ce2fcb7ea832') def test_dhcpv6_stateless_no_ra(self): - """When subnets configured with dnsmasq SLAAC and DHCP stateless - and there is no radvd, port shall receive IP address calculated - from its MAC and mask of subnet. - """ + # NOTE: When subnets configured with dnsmasq SLAAC and DHCP stateless + # and there is no radvd, port shall receive IP address calculated + # from its MAC and mask of subnet. for ra_mode, add_mode in ( (None, 'slaac'), (None, 'dhcpv6-stateless'), @@ -158,9 +156,8 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('21635b6f-165a-4d42-bf49-7d195e47342f') def test_dhcpv6_stateless_no_ra_no_dhcp(self): - """If no radvd option and no dnsmasq option is configured - port shall receive IP from fixed IPs list of subnet. - """ + # NOTE: If no radvd option and no dnsmasq option is configured + # port shall receive IP from fixed IPs list of subnet. real_ip, eui_ip = self._get_ips_from_subnet() self._clean_network() self.assertNotEqual(eui_ip, real_ip, @@ -171,11 +168,10 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('4544adf7-bb5f-4bdc-b769-b3e77026cef2') def test_dhcpv6_two_subnets(self): - """When one IPv6 subnet configured with dnsmasq SLAAC or DHCP stateless - and other IPv6 is with DHCP stateful, port shall receive EUI-64 IP - addresses from first subnet and DHCP address from second one. - Order of subnet creating should be unimportant. - """ + # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP + # stateless and other IPv6 is with DHCP stateful, port shall receive + # EUI-64 IP addresses from first subnet and DHCP address from second + # one. Order of subnet creating should be unimportant. for order in ("slaac_first", "dhcp_first"): for ra_mode, add_mode in ( ('slaac', 'slaac'), @@ -221,11 +217,10 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('4256c61d-c538-41ea-9147-3c450c36669e') def test_dhcpv6_64_subnets(self): - """When one IPv6 subnet configured with dnsmasq SLAAC or DHCP stateless - and other IPv4 is with DHCP of IPv4, port shall receive EUI-64 IP - addresses from first subnet and IPv4 DHCP address from second one. - Order of subnet creating should be unimportant. - """ + # NOTE: When one IPv6 subnet configured with dnsmasq SLAAC or DHCP + # stateless and other IPv4 is with DHCP of IPv4, port shall receive + # EUI-64 IP addresses from first subnet and IPv4 DHCP address from + # second one. Order of subnet creating should be unimportant. for order in ("slaac_first", "dhcp_first"): for ra_mode, add_mode in ( ('slaac', 'slaac'), @@ -265,9 +260,8 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('4ab211a0-276f-4552-9070-51e27f58fecf') def test_dhcp_stateful(self): - """With all options below, DHCPv6 shall allocate address - from subnet pool to port. - """ + # NOTE: With all options below, DHCPv6 shall allocate address from + # subnet pool to port. for ra_mode, add_mode in ( ('dhcpv6-stateful', 'dhcpv6-stateful'), ('dhcpv6-stateful', None), @@ -287,10 +281,9 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('51a5e97f-f02e-4e4e-9a17-a69811d300e3') def test_dhcp_stateful_fixedips(self): - """With all options below, port shall be able to get - requested IP from fixed IP range not depending on - DHCP stateful (not SLAAC!) settings configured. - """ + # NOTE: With all options below, port shall be able to get + # requested IP from fixed IP range not depending on + # DHCP stateful (not SLAAC!) settings configured. for ra_mode, add_mode in ( ('dhcpv6-stateful', 'dhcpv6-stateful'), ('dhcpv6-stateful', None), @@ -316,9 +309,8 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('98244d88-d990-4570-91d4-6b25d70d08af') def test_dhcp_stateful_fixedips_outrange(self): - """When port gets IP address from fixed IP range it - shall be checked if it's from subnets range. - """ + # NOTE: When port gets IP address from fixed IP range it + # shall be checked if it's from subnets range. kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful', 'ipv6_address_mode': 'dhcpv6-stateful'} subnet = self.create_subnet(self.network, **kwargs) @@ -334,9 +326,8 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('57b8302b-cba9-4fbb-8835-9168df029051') def test_dhcp_stateful_fixedips_duplicate(self): - """When port gets IP address from fixed IP range it - shall be checked if it's not duplicate. - """ + # NOTE: When port gets IP address from fixed IP range it + # shall be checked if it's not duplicate. kwargs = {'ipv6_ra_mode': 'dhcpv6-stateful', 'ipv6_address_mode': 'dhcpv6-stateful'} subnet = self.create_subnet(self.network, **kwargs) @@ -367,9 +358,8 @@ class NetworksTestDHCPv6(base.BaseNetworkTest): @test.idempotent_id('e98f65db-68f4-4330-9fea-abd8c5192d4d') def test_dhcp_stateful_router(self): - """With all options below the router interface shall - receive DHCPv6 IP address from allocation pool. - """ + # NOTE: With all options below the router interface shall + # receive DHCPv6 IP address from allocation pool. for ra_mode, add_mode in ( ('dhcpv6-stateful', 'dhcpv6-stateful'), ('dhcpv6-stateful', None), diff --git a/tempest/api/network/test_extensions.py b/tempest/api/network/test_extensions.py index d6b03ebf51..b83d2b08bc 100644 --- a/tempest/api/network/test_extensions.py +++ b/tempest/api/network/test_extensions.py @@ -19,10 +19,7 @@ from tempest import test class ExtensionsTestJSON(base.BaseNetworkTest): - - """ - Tests the following operations in the Neutron API using the REST client for - Neutron: + """Tests the following operations in the Neutron API: List all available extensions diff --git a/tempest/api/network/test_extra_dhcp_options.py b/tempest/api/network/test_extra_dhcp_options.py index 7924f387c0..062bc698dd 100644 --- a/tempest/api/network/test_extra_dhcp_options.py +++ b/tempest/api/network/test_extra_dhcp_options.py @@ -19,9 +19,7 @@ from tempest import test class ExtraDHCPOptionsTestJSON(base.BaseNetworkTest): - """ - Tests the following operations with the Extra DHCP Options Neutron API - extension: + """Tests the following operations with the Extra DHCP Options: port create port list diff --git a/tempest/api/network/test_floating_ips.py b/tempest/api/network/test_floating_ips.py index b7963114b3..e9a553a19b 100644 --- a/tempest/api/network/test_floating_ips.py +++ b/tempest/api/network/test_floating_ips.py @@ -24,9 +24,7 @@ CONF = config.CONF class FloatingIPTestJSON(base.BaseNetworkTest): - """ - Tests the following operations in the Neutron API using the REST client for - Neutron: + """Tests the following operations in the Neutron API: Create a Floating IP Update a Floating IP diff --git a/tempest/api/network/test_floating_ips_negative.py b/tempest/api/network/test_floating_ips_negative.py index e8624d8d70..5f56fec55c 100644 --- a/tempest/api/network/test_floating_ips_negative.py +++ b/tempest/api/network/test_floating_ips_negative.py @@ -25,8 +25,7 @@ CONF = config.CONF class FloatingIPNegativeTestJSON(base.BaseNetworkTest): - """ - Test the following negative operations for floating ips: + """Test the following negative operations for floating ips: Create floatingip with a port that is unreachable to external network Create floatingip in private network diff --git a/tempest/api/network/test_metering_extensions.py b/tempest/api/network/test_metering_extensions.py index ee0dcb083f..a213f92d07 100644 --- a/tempest/api/network/test_metering_extensions.py +++ b/tempest/api/network/test_metering_extensions.py @@ -23,9 +23,7 @@ LOG = logging.getLogger(__name__) class MeteringTestJSON(base.BaseAdminNetworkTest): - """ - Tests the following operations in the Neutron API using the REST client for - Neutron: + """Tests the following operations in the Neutron API: List, Show, Create, Delete Metering labels List, Show, Create, Delete Metering labels rules diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py index 5039a69422..a26614283c 100644 --- a/tempest/api/network/test_networks.py +++ b/tempest/api/network/test_networks.py @@ -28,9 +28,7 @@ CONF = config.CONF class NetworksTest(base.BaseNetworkTest): - """ - Tests the following operations in the Neutron API using the REST client for - Neutron: + """Tests the following operations in the Neutron API: create a network for a tenant list tenant's networks @@ -95,9 +93,8 @@ class NetworksTest(base.BaseNetworkTest): @classmethod def _create_subnet_with_last_subnet_block(cls, network, ip_version): - """Derive last subnet CIDR block from tenant CIDR and - create the subnet with that derived CIDR - """ + # Derive last subnet CIDR block from tenant CIDR and + # create the subnet with that derived CIDR if ip_version == 4: cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr) mask_bits = CONF.network.tenant_network_mask_bits @@ -133,9 +130,8 @@ class NetworksTest(base.BaseNetworkTest): return [{'start': str(gateway + 2), 'end': str(gateway + 3)}] def subnet_dict(self, include_keys): - """Return a subnet dict which has include_keys and their corresponding - value from self._subnet_data - """ + # Return a subnet dict which has include_keys and their corresponding + # value from self._subnet_data return dict((key, self._subnet_data[self._ip_version][key]) for key in include_keys) @@ -405,9 +401,7 @@ class NetworksTest(base.BaseNetworkTest): class BulkNetworkOpsTestJSON(base.BaseNetworkTest): - """ - Tests the following operations in the Neutron API using the REST client for - Neutron: + """Tests the following operations in the Neutron API: bulk network creation bulk subnet creation diff --git a/tempest/api/network/test_ports.py b/tempest/api/network/test_ports.py index d0ed1f263b..43da1c4546 100644 --- a/tempest/api/network/test_ports.py +++ b/tempest/api/network/test_ports.py @@ -28,8 +28,7 @@ CONF = config.CONF class PortsTestJSON(sec_base.BaseSecGroupTest): - """ - Test the following operations for ports: + """Test the following operations for ports: port create port delete diff --git a/tempest/api/network/test_subnetpools_extensions.py b/tempest/api/network/test_subnetpools_extensions.py index 09478ca487..8a61ff87d3 100644 --- a/tempest/api/network/test_subnetpools_extensions.py +++ b/tempest/api/network/test_subnetpools_extensions.py @@ -22,9 +22,7 @@ CONF = config.CONF class SubnetPoolsTestJSON(base.BaseNetworkTest): - """ - Tests the following operations in the subnetpools API using the REST client - for Neutron: + """Tests the following operations in the subnetpools API: Create a subnet pool. Update a subnet pool.