Fix H404/405 violations for remaining

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 remaining.

Change-Id: I3abac40ebb33836980c119d59bc97f035b213c0a
This commit is contained in:
Ken'ichi Ohmichi 2015-11-19 09:48:27 +00:00
parent 0afa8819e4
commit 2e2ee19179
19 changed files with 115 additions and 122 deletions

View File

@ -154,10 +154,7 @@ LOG = logging.getLogger(__name__)
class Manager(manager.Manager):
"""
Top level manager for OpenStack tempest clients
"""
"""Top level manager for OpenStack tempest clients"""
default_params = {
'disable_ssl_certificate_validation':

View File

@ -35,7 +35,9 @@ group_regex=([^\.]*\.)*
def get_tempest_default_config_dir():
"""Returns the correct default config dir to support both cases of
"""Get default config directory of tempest
Returns the correct default config dir to support both cases of
tempest being or not installed in a virtualenv.
Cases considered:
- no virtual env, python2: real_prefix and base_prefix not set

View File

@ -33,8 +33,7 @@ LOG = logging.getLogger(__name__)
def discover_stress_tests(path="./", filter_attr=None, call_inherited=False):
"""Discovers all tempest tests and create action out of them
"""
"""Discovers all tempest tests and create action out of them"""
LOG.info("Start test discovery")
tests = []
testloader = loader.TestLoader()

View File

@ -17,8 +17,7 @@ import testtools
class TempestException(Exception):
"""
Base Tempest Exception
"""Base Tempest Exception
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd

View File

@ -23,16 +23,15 @@ CONF = config.CONF
class Manager(object):
"""
Base manager class
"""Base manager class
Manager objects are responsible for providing a configuration object
and a client object for a test case to use in performing actions.
"""
def __init__(self, credentials):
"""
"""Initialization of base manager class
Credentials to be used within the various client classes managed by the
Manager object must be defined.

View File

@ -27,10 +27,7 @@ LOG = logging.getLogger(__name__)
class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest):
"""
This test case checks VM connectivity after some advanced
instance operations executed:
"""Check VM connectivity after some advanced instance operations executed:
* Stop/Start an instance
* Reboot an instance

View File

@ -36,7 +36,8 @@ Floating_IP_tuple = collections.namedtuple('Floating_IP_tuple',
class TestNetworkBasicOps(manager.NetworkScenarioTest):
"""
"""The test suite of network basic operations
This smoke test suite assumes that Nova has been configured to
boot VM's with Neutron-managed networking, and attempts to
verify network connectivity as follows:
@ -123,9 +124,9 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
self.floating_ip_tuple = Floating_IP_tuple(floating_ip, server)
def check_networks(self):
"""
Checks that we see the newly created network/subnet/router via
checking the result of list_[networks,routers,subnets]
"""Checks that we see the newly created network/subnet/router
via checking the result of list_[networks,routers,subnets]
"""
seen_nets = self._list_networks()
@ -182,7 +183,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
def check_public_network_connectivity(
self, should_connect=True, msg=None,
should_check_floating_ip_status=True):
"""Verifies connectivty to a VM via public network and floating IP,
"""Verifies connectivty to a VM via public network and floating IP
and verifies floating IP has resource status is correct.
:param should_connect: bool. determines if connectivity check is
@ -294,8 +296,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
def _check_network_internal_connectivity(self, network,
should_connect=True):
"""
via ssh check VM internal connectivity:
"""via ssh check VM internal connectivity:
- ping internal gateway and DHCP port, implying in-tenant connectivity
pinging both, because L3 and DHCP agents might be on different nodes
"""
@ -312,10 +314,7 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
should_connect)
def _check_network_external_connectivity(self):
"""
ping public network default gateway to imply external connectivity
"""
"""ping default gateway to imply external connectivity"""
if not CONF.network.public_network_id:
msg = 'public network not defined.'
LOG.info(msg)
@ -359,7 +358,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
@test.idempotent_id('f323b3ba-82f8-4db7-8ea6-6a895869ec49')
@test.services('compute', 'network')
def test_network_basic_ops(self):
"""
"""Basic network operation test
For a freshly-booted VM with an IP address ("port") on a given
network:
@ -412,7 +412,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
'Baremetal relies on a shared physical network.')
@test.services('compute', 'network')
def test_connectivity_between_vms_on_different_networks(self):
"""
"""Test connectivity between VMs on different networks
For a freshly-booted VM with an IP address ("port") on a given
network:
@ -460,7 +461,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
'vnic_type direct or macvtap')
@test.services('compute', 'network')
def test_hotplug_nic(self):
"""
"""Test hotplug network interface
1. create a new network, with no gateway (to prevent overwriting VM's
gateway)
2. connect VM to new network
@ -480,7 +482,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
'network')
@test.services('compute', 'network')
def test_update_router_admin_state(self):
"""
"""Test to update admin state up of router
1. Check public connectivity before updating
admin_state_up attribute of router to False
2. Check public connectivity after updating
@ -512,8 +515,9 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
"DHCP client is not available.")
@test.services('compute', 'network')
def test_subnet_details(self):
"""Tests that subnet's extra configuration details are affecting
the VMs. This test relies on non-shared, isolated tenant networks.
"""Tests that subnet's extra configuration details are affecting VMs.
This test relies on non-shared, isolated tenant networks.
NOTE: Neutron subnets push data to servers via dhcp-agent, so any
update in subnet requires server to actively renew its DHCP lease.
@ -567,12 +571,11 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
"Failed to update subnet's nameservers")
def check_new_dns_server():
"""Server needs to renew its dhcp lease in order to get the new dns
definitions from subnet
NOTE(amuller): we are renewing the lease as part of the retry
because Neutron updates dnsmasq asynchronously after the
subnet-update API call returns.
"""
# NOTE: Server needs to renew its dhcp lease in order to get new
# definitions from subnet
# NOTE(amuller): we are renewing the lease as part of the retry
# because Neutron updates dnsmasq asynchronously after the
# subnet-update API call returns.
ssh_client.renew_lease(fixed_ip=floating_ip['fixed_ip_address'])
if ssh_client.get_dns_servers() != [alt_dns_server]:
LOG.debug("Failed to update DNS nameservers")
@ -594,7 +597,8 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
"by the test environment")
@test.services('compute', 'network')
def test_update_instance_port_admin_state(self):
"""
"""Test to update admin_state_up attribute of instance port
1. Check public connectivity before updating
admin_state_up attribute of instance port to False
2. Check public connectivity after updating
@ -625,8 +629,10 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
'supported in the version of Nova being tested.')
@test.services('compute', 'network')
def test_preserve_preexisting_port(self):
"""Tests that a pre-existing port provided on server boot is not
deleted if the server is deleted.
"""Test preserve pre-existing port
Tests that a pre-existing port provided on server boot is not deleted
if the server is deleted.
Nova should unbind the port from the instance on delete if the port was
not created by Nova as part of the boot request.

View File

@ -97,6 +97,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
class TenantProperties(object):
"""helper class to save tenant details
id
credentials
network
@ -298,6 +299,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
def _deploy_tenant(self, tenant_or_id):
"""creates:
network
subnet
router (if public not defined)
@ -374,8 +376,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
should_succeed=False)
def _test_cross_tenant_allow(self, source_tenant, dest_tenant):
"""
check for each direction:
"""check for each direction:
creating rule for tenant incoming traffic enables only 1way traffic
"""
ruleset = dict(
@ -408,10 +410,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
self._check_connectivity(access_point_ssh_2, ip)
def _verify_mac_addr(self, tenant):
"""
verify that VM (tenant's access point) has the same ip,mac as listed in
port list
"""
"""Verify that VM has the same ip, mac as listed in port"""
access_point_ssh = self._connect_to_access_point(tenant)
mac_addr = access_point_ssh.get_mac_address()
mac_addr = mac_addr.strip().lower()
@ -466,9 +466,9 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
@test.idempotent_id('f4d556d7-1526-42ad-bafb-6bebf48568f6')
@test.services('compute', 'network')
def test_port_update_new_security_group(self):
"""
This test verifies the traffic after updating the vm port with new
security group having appropriate rule.
"""Verifies the traffic after updating the vm port
With new security group having appropriate rule.
"""
new_tenant = self.primary_tenant
@ -517,8 +517,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
@test.idempotent_id('d2f77418-fcc4-439d-b935-72eca704e293')
@test.services('compute', 'network')
def test_multiple_security_groups(self):
"""
This test verifies multiple security groups and checks that rules
"""Verify multiple security groups and checks that rules
provided in the both the groups is applied onto VM
"""
tenant = self.primary_tenant
@ -536,13 +536,11 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
secgroup=tenant.security_groups['default'],
**ruleset
)
"""
Vm now has 2 security groups one with ssh rule(
already added in setUp() method),and other with icmp rule
(added in the above step).The check_vm_connectivity tests
-that vm ping test is successful
-ssh to vm is successful
"""
# NOTE: Vm now has 2 security groups one with ssh rule(
# already added in setUp() method),and other with icmp rule
# (added in the above step).The check_vm_connectivity tests
# -that vm ping test is successful
# -ssh to vm is successful
self.check_vm_connectivity(ip,
username=ssh_login,
private_key=private_key,
@ -552,10 +550,7 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
@test.idempotent_id('7c811dcc-263b-49a3-92d2-1b4d8405f50c')
@test.services('compute', 'network')
def test_port_security_disable_security_group(self):
"""
This test verifies port_security_enabled=False disables
the default security group rules.
"""
"""Verify the default security group rules is disabled."""
new_tenant = self.primary_tenant
# Create server

View File

@ -32,9 +32,7 @@ class QuotaClassesClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def update_quota_class_set(self, quota_class_id, **kwargs):
"""
Updates the quota class's limits for one or more resources.
"""
"""Updates the quota class's limits for one or more resources."""
post_body = json.dumps({'quota_class_set': kwargs})
resp, body = self.put('os-quota-class-sets/%s' % quota_class_id,

View File

@ -42,9 +42,7 @@ class QuotasClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def update_quota_set(self, tenant_id, user_id=None, **kwargs):
"""
Updates the tenant's quota limits for one or more resources
"""
"""Updates the tenant's quota limits for one or more resources"""
post_body = json.dumps({'quota_set': kwargs})
if user_id:

View File

@ -23,8 +23,8 @@ from tempest.common import service_client
class SecurityGroupDefaultRulesClient(service_client.ServiceClient):
def create_security_default_group_rule(self, **kwargs):
"""
Creating security group default rules.
"""Creating security group default rules.
ip_protocol : ip_protocol (icmp, tcp, udp).
from_port: Port at start of range.
to_port : Port at end of range.

View File

@ -22,8 +22,8 @@ from tempest.common import service_client
class SecurityGroupRulesClient(service_client.ServiceClient):
def create_security_group_rule(self, **kwargs):
"""
Creating a new security group rules.
"""Creating a new security group rules.
parent_group_id :ID of Security group
ip_protocol : ip_proto (icmp, tcp, udp).
from_port: Port at start of range.

View File

@ -44,8 +44,8 @@ class SecurityGroupsClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def create_security_group(self, **kwargs):
"""
Creates a new security group.
"""Creates a new security group.
name (Required): Name of security group.
description (Required): Description of security group.
"""
@ -56,8 +56,8 @@ class SecurityGroupsClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def update_security_group(self, security_group_id, **kwargs):
"""
Update a security group.
"""Update a security group.
security_group_id: a security_group to update
name: new name of security group
description: new description of security group

View File

@ -23,8 +23,8 @@ from tempest.common import service_client
class ServerGroupsClient(service_client.ServiceClient):
def create_server_group(self, **kwargs):
"""
Create the server group
"""Create the server group
name : Name of the server-group
policies : List of the policies - affinity/anti-affinity)
"""

View File

@ -34,8 +34,8 @@ class ServicesClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def enable_service(self, **kwargs):
"""
Enable service on a host
"""Enable service on a host
host_name: Name of host
binary: Service binary
"""
@ -46,8 +46,8 @@ class ServicesClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def disable_service(self, **kwargs):
"""
Disable service on a host
"""Disable service on a host
host_name: Name of host
binary: Service binary
"""

View File

@ -46,8 +46,8 @@ class VolumesClient(service_client.ServiceClient):
return service_client.ResponseBody(resp, body)
def create_volume(self, **kwargs):
"""
Creates a new Volume.
"""Creates a new Volume.
size(Required): Size of volume in GB.
Following optional keyword arguments are accepted:
display_name: Optional Volume Name.

View File

@ -211,6 +211,7 @@ atexit.register(validate_tearDownClass)
class BaseTestCase(testtools.testcase.WithAttributes,
testtools.TestCase):
"""The test base class defines Tempest framework for class level fixtures.
`setUpClass` and `tearDownClass` are defined here and cannot be overwritten
by subclasses (enforced via hacking rule T105).
@ -315,8 +316,10 @@ class BaseTestCase(testtools.testcase.WithAttributes,
@classmethod
def skip_checks(cls):
"""Class level skip checks. Subclasses verify in here all
conditions that might prevent the execution of the entire test class.
"""Class level skip checks.
Subclasses verify in here all conditions that might prevent the
execution of the entire test class.
Checks implemented here may not make use API calls, and should rely on
configuration alone.
In general skip checks that require an API call are discouraged.
@ -343,6 +346,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
@classmethod
def setup_credentials(cls):
"""Allocate credentials and the client managers from them.
A test class that requires network resources must override
setup_credentials and defined the required resources before super
is invoked.
@ -380,8 +384,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
@classmethod
def resource_setup(cls):
"""Class level resource setup for test cases.
"""
"""Class level resource setup for test cases."""
if hasattr(cls, "os"):
cls.validation_resources = vresources.create_validation_resources(
cls.os, cls.validation_resources)
@ -392,6 +395,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
@classmethod
def resource_cleanup(cls):
"""Class level resource cleanup for test cases.
Resource cleanup must be able to handle the case of partially setup
resources, in case a failure during `resource_setup` should happen.
"""
@ -523,9 +527,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
@classmethod
def clear_credentials(cls):
"""
Clears creds if set
"""
"""Clears creds if set"""
if hasattr(cls, '_creds_provider'):
cls._creds_provider.clear_creds()
@ -534,6 +536,7 @@ class BaseTestCase(testtools.testcase.WithAttributes,
security_group=None,
security_group_rules=None):
"""Specify which ssh server validation resources should be created.
Each of the argument must be set to either None, True or False, with
None - use default from config (security groups and security group
rules get created when set to None)
@ -631,10 +634,11 @@ class NegativeAutoTest(BaseTestCase):
@staticmethod
def load_tests(*args):
"""
Wrapper for testscenarios to set the mandatory scenarios variable
only in case a real test loader is in place. Will be automatically
called in case the variable "load_tests" is set.
"""Wrapper for testscenarios
To set the mandatory scenarios variable only in case a real test
loader is in place. Will be automatically called in case the variable
"load_tests" is set.
"""
if getattr(args[0], 'suiteClass', None) is not None:
loader, standard_tests, pattern = args
@ -649,8 +653,7 @@ class NegativeAutoTest(BaseTestCase):
@staticmethod
def generate_scenario(description):
"""
Generates the test scenario list for a given description.
"""Generates the test scenario list for a given description.
:param description: A file or dictionary with the following entries:
name (required) name for the api
@ -694,7 +697,8 @@ class NegativeAutoTest(BaseTestCase):
return scenario_list
def execute(self, description):
"""
"""Execute a http call
Execute a http call on an api that are expected to
result in client errors. First it uses invalid resources that are part
of the url, and then invalid data for queries and http request bodies.
@ -788,7 +792,8 @@ class NegativeAutoTest(BaseTestCase):
@classmethod
def set_resource(cls, name, resource):
"""
"""Register a resoruce for a test
This function can be used in setUpClass context to register a resoruce
for a test.
@ -799,10 +804,10 @@ class NegativeAutoTest(BaseTestCase):
cls._resources[name] = resource
def get_resource(self, name):
"""
Return a valid uuid for a type of resource. If a real resource is
needed as part of a url then this method should return one. Otherwise
it can return None.
"""Return a valid uuid for a type of resource.
If a real resource is needed as part of a url then this method should
return one. Otherwise it can return None.
:param name: The name of the kind of resource such as "flavor", "role",
etc.
@ -819,9 +824,7 @@ class NegativeAutoTest(BaseTestCase):
def SimpleNegativeAutoTest(klass):
"""
This decorator registers a test function on basis of the class name.
"""
"""This decorator registers a test function on basis of the class name."""
@attr(type=['negative'])
def generic_test(self):
if hasattr(self, '_schema'):
@ -838,10 +841,9 @@ def SimpleNegativeAutoTest(klass):
def call_until_true(func, duration, sleep_for):
"""
Call the given function until it returns True (and return True) or
until the specified duration (in seconds) elapses (and return
False).
"""Call the given function until it returns True (and return True)
or until the specified duration (in seconds) elapses (and return False).
:param func: A zero argument callable that returns True on success.
:param duration: The number of seconds for which to attempt a

View File

@ -25,14 +25,14 @@ LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class TempestPlugin(object):
"""A TempestPlugin class provides the basic hooks for an external
plugin to provide tempest the necessary information to run the plugin.
"""Provide basic hooks for an external plugin
To provide tempest the necessary information to run the plugin.
"""
@abc.abstractmethod
def load_tests(self):
"""Method to return the information necessary to load the tests in the
plugin.
"""Return the information necessary to load the tests in the plugin.
:return: a tuple with the first value being the test_dir and the second
being the top_level
@ -42,9 +42,10 @@ class TempestPlugin(object):
@abc.abstractmethod
def register_opts(self, conf):
"""Method to add additional configuration options to tempest. This
method will be run for the plugin during the register_opts() function
in tempest.config
"""Add additional configuration options to tempest.
This method will be run for the plugin during the register_opts()
function in tempest.config
:param ConfigOpts conf: The conf object that can be used to register
additional options on.
@ -53,7 +54,7 @@ class TempestPlugin(object):
@abc.abstractmethod
def get_opt_lists(self):
"""Method to get a list of options for sample config generation
"""Get a list of options for sample config generation
:return option_list: A list of tuples with the group name and options
in that group.

View File

@ -129,6 +129,6 @@ import_exceptions = tempest.services
# E123 skipped because it is ignored by default in the default pep8
# E129 skipped because it is too limiting when combined with other rules
# Skipped because of new hacking 0.9: H405
ignore = E125,E123,E129,H404,H405
ignore = E125,E123,E129
show-source = True
exclude = .git,.venv,.tox,dist,doc,openstack,*egg