Fix H404/405 violations for common code

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 common code.

Change-Id: I5ddedcdd4d00ddbd53e1006ba40dce447fba3c20
This commit is contained in:
Ken'ichi Ohmichi 2015-11-19 08:23:22 +00:00
parent 88363cbe27
commit cb67d2dd46
10 changed files with 41 additions and 67 deletions

View File

@ -24,10 +24,11 @@ LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class CredsClient(object):
"""This class is a wrapper around the identity clients, to provide a
single interface for managing credentials in both v2 and v3 cases.
It's not bound to created credentials, only to a specific set of admin
credentials used for generating credentials.
"""This class is a wrapper around the identity clients
to provide a single interface for managing credentials in both v2 and v3
cases. It's not bound to created credentials, only to a specific set of
admin credentials used for generating credentials.
"""
def __init__(self, identity_client):

View File

@ -28,6 +28,7 @@ class CredentialProvider(object):
def __init__(self, identity_version, name=None, network_resources=None,
credentials_domain=None, admin_role=None):
"""A CredentialProvider supplies credentials to test classes.
:param identity_version: Identity version of the credentials provided
:param name: Name of the calling test. Included in provisioned
credentials when credentials are provisioned on the fly

View File

@ -292,10 +292,7 @@ def get_credentials(fill_in=True, identity_version=None, **kwargs):
class ConfiguredUserManager(clients.Manager):
"""
Manager object that uses the `user` credentials for its
managed client objects
"""
"""Manager that uses user credentials for its managed client objects"""
def __init__(self, service=None):
super(ConfiguredUserManager, self).__init__(
@ -304,11 +301,7 @@ class ConfiguredUserManager(clients.Manager):
class AdminManager(clients.Manager):
"""
Manager object that uses the admin credentials for its
managed client objects
"""
"""Manager that uses admin credentials for its managed client objects"""
def __init__(self, service=None):
super(AdminManager, self).__init__(

View File

@ -19,8 +19,7 @@ from testtools import helpers
class ExistsAllResponseHeaders(object):
"""
Specific matcher to check the existence of Swift's response headers
"""Specific matcher to check the existence of Swift's response headers
This matcher checks the existence of common headers for each HTTP method
or the target, which means account, container or object.
@ -30,7 +29,8 @@ class ExistsAllResponseHeaders(object):
"""
def __init__(self, target, method):
"""
"""Initialization of ExistsAllResponseHeaders
param: target Account/Container/Object
param: method PUT/GET/HEAD/DELETE/COPY/POST
"""
@ -38,7 +38,8 @@ class ExistsAllResponseHeaders(object):
self.method = method
def match(self, actual):
"""
"""Check headers
param: actual HTTP response headers
"""
# Check common headers for all HTTP methods
@ -95,10 +96,7 @@ class ExistsAllResponseHeaders(object):
class NonExistentHeader(object):
"""
Informs an error message for end users in the case of missing a
certain header in Swift's responses
"""
"""Informs an error message in the case of missing a certain header"""
def __init__(self, header):
self.header = header
@ -111,9 +109,7 @@ class NonExistentHeader(object):
class AreAllWellFormatted(object):
"""
Specific matcher to check the correctness of formats of values of Swift's
response headers
"""Specific matcher to check the correctness of formats of values
This matcher checks the format of values of response headers.
When checking the format of values of 'specific' headers such as
@ -149,10 +145,7 @@ class AreAllWellFormatted(object):
class InvalidFormat(object):
"""
Informs an error message for end users if a format of a certain header
is invalid
"""
"""Informs an error message if a format of a certain header is invalid"""
def __init__(self, key, value):
self.key = key
@ -166,8 +159,9 @@ class InvalidFormat(object):
class MatchesDictExceptForKeys(object):
"""Matches two dictionaries. Verifies all items are equals except for those
identified by a list of keys.
"""Matches two dictionaries.
Verifies all items are equals except for those identified by a list of keys
"""
def __init__(self, expected, excluded_keys=None):

View File

@ -72,9 +72,9 @@ class DynamicCredentialProvider(cred_provider.CredentialProvider):
self.identity_admin_client, self.creds_domain_name)
def _get_admin_clients(self):
"""
Returns a tuple with instances of the following admin clients (in this
order):
"""Returns a tuple with instances of the following admin clients
(in this order):
identity
network
"""

View File

@ -41,9 +41,7 @@ def generator_type(*args, **kwargs):
def simple_generator(fn):
"""
Decorator for simple generators that return one value
"""
"""Decorator for simple generators that return one value"""
@functools.wraps(fn)
def wrapped(self, schema):
result = fn(self, schema)
@ -110,9 +108,7 @@ class BasicGeneratorSet(object):
jsonschema.validate(schema, self.schema)
def generate_scenarios(self, schema, path=None):
"""
Generates the scenario (all possible test cases) out of the given
schema.
"""Generate scenario (all possible test cases) out of the given schema
:param schema: a dict style schema (see ``BasicGeneratorSet.schema``)
:param path: the schema path if the given schema is a subschema
@ -157,9 +153,10 @@ class BasicGeneratorSet(object):
return scenarios
def generate_payload(self, test, schema):
"""
Generates one jsonschema out of the given test. It's mandatory to use
generate_scenarios before to register all needed variables to the test.
"""Generates one jsonschema out of the given test.
It's mandatory to use generate_scenarios before to register all needed
variables to the test.
:param test: A test object (scenario) with all _negtest variables on it
:param schema: schema for the test

View File

@ -203,8 +203,7 @@ class HTTPClient(object):
class OpenSSLConnectionDelegator(object):
"""
An OpenSSL.SSL.Connection delegator.
"""An OpenSSL.SSL.Connection delegator.
Supplies an additional 'makefile' method which httplib requires
and is not present in OpenSSL.SSL.Connection.
@ -225,9 +224,8 @@ class OpenSSLConnectionDelegator(object):
class VerifiedHTTPSConnection(httplib.HTTPSConnection):
"""
Extended HTTPSConnection which uses the OpenSSL library
for enhanced SSL support.
"""Extended HTTPSConnection which uses OpenSSL library for enhanced SSL
Note: Much of this functionality can eventually be replaced
with native Python 3.3 code.
"""
@ -247,11 +245,10 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
@staticmethod
def host_matches_cert(host, x509):
"""
Verify that the the x509 certificate we have received
from 'host' correctly identifies the server we are
connecting to, ie that the certificate's Common Name
or a Subject Alternative Name matches 'host'.
"""Verify that the x509 certificate we have received from 'host'
Identifies the server we are connecting to, ie that the certificate's
Common Name or a Subject Alternative Name matches 'host'.
"""
# First see if we can match the CN
if x509.get_subject().commonName == host:
@ -289,9 +286,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
return preverify_ok
def setcontext(self):
"""
Set up the OpenSSL context.
"""
"""Set up the OpenSSL context."""
self.context = OpenSSL.SSL.Context(OpenSSL.SSL.SSLv23_METHOD)
if self.ssl_compression is False:
@ -336,10 +331,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
self.context.set_default_verify_paths()
def connect(self):
"""
Connect to an SSL port using the OpenSSL library and apply
per-connection parameters.
"""
"""Connect to SSL port and apply per-connection parameters."""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.timeout is not None:
# '0' microseconds

View File

@ -22,9 +22,7 @@ CONF = config.CONF
class NegativeRestClient(service_client.ServiceClient):
"""
Version of RestClient that does not raise exceptions.
"""
"""Version of RestClient that does not raise exceptions."""
def __init__(self, auth_provider, service,
build_interval=None, build_timeout=None,
disable_ssl_certificate_validation=None,
@ -43,9 +41,7 @@ class NegativeRestClient(service_client.ServiceClient):
trace_requests=trace_requests)
def _get_region_and_endpoint_type(self, service):
"""
Returns the region for a specific service
"""
"""Returns the region for a specific service"""
service_region = None
service_endpoint_type = None
for cfgname in dir(CONF._config):

View File

@ -57,8 +57,7 @@ class ResponseBody(dict):
class ResponseBodyData(object):
"""Class that wraps an http response and string data into a single value.
"""
"""Class that wraps an http response and string data into a single value"""
def __init__(self, response, data):
self.response = response

View File

@ -57,6 +57,7 @@ class RemoteClient(object):
def validate_authentication(self):
"""Validate ssh connection and authentication
This method raises an Exception when the validation fails.
"""
self.ssh_client.test_connection_auth()