Fix and enable gating on H402

Docstring summaries need punctuation.

Change-Id: I1b740c13d5fedf9a625ca0807c908f651ee08406
This commit is contained in:
Dirk Mueller 2013-07-02 10:07:49 +02:00
parent 8b40f57338
commit f2ad113d1c
17 changed files with 62 additions and 63 deletions

View File

@ -168,7 +168,7 @@ class AccessInfo(dict):
@property
def tenant_name(self):
"""Synonym for project_name"""
"""Synonym for project_name."""
return self.project_name
@property
@ -211,7 +211,7 @@ class AccessInfo(dict):
@property
def tenant_id(self):
"""Synonym for project_id """
"""Synonym for project_id."""
return self.project_id
@property

View File

@ -29,12 +29,12 @@ class EndpointNotFound(Exception):
class EmptyCatalog(Exception):
"""The service catalog is empty. """
"""The service catalog is empty."""
pass
class NoUniqueMatch(Exception):
"""Unable to find unique resource"""
"""Unable to find unique resource."""
pass

View File

@ -118,7 +118,7 @@ def derive_keys(token, secret, strategy):
def sign_data(key, data):
"""Sign the data using the defined function and the derived key"""
"""Sign the data using the defined function and the derived key."""
mac = hmac.new(key, data, HASH_FUNCTION).digest()
return base64.b64encode(mac)

View File

@ -32,7 +32,7 @@ PERFECT_TIME_FORMAT = _ISO8601_TIME_FORMAT_SUBSECOND
def isotime(at=None, subsecond=False):
"""Stringify time in ISO 8601 format"""
"""Stringify time in ISO 8601 format."""
if not at:
at = utcnow()
st = at.strftime(_ISO8601_TIME_FORMAT
@ -44,7 +44,7 @@ def isotime(at=None, subsecond=False):
def parse_isotime(timestr):
"""Parse time from ISO 8601 format"""
"""Parse time from ISO 8601 format."""
try:
return iso8601.parse_date(timestr)
except iso8601.ParseError as e:
@ -66,7 +66,7 @@ def parse_strtime(timestr, fmt=PERFECT_TIME_FORMAT):
def normalize_time(timestamp):
"""Normalize time in arbitrary timezone to UTC naive object"""
"""Normalize time in arbitrary timezone to UTC naive object."""
offset = timestamp.utcoffset()
if offset is None:
return timestamp
@ -103,7 +103,7 @@ def utcnow():
def iso8601_from_timestamp(timestamp):
"""Returns a iso8601 formated date from timestamp"""
"""Returns a iso8601 formated date from timestamp."""
return isotime(datetime.datetime.utcfromtimestamp(timestamp))

View File

@ -46,7 +46,7 @@ def print_list(objs, fields, formatters={}, order_by=None):
def _word_wrap(string, max_length=0):
"""wrap long strings to be no longer then max_length"""
"""wrap long strings to be no longer then max_length."""
if max_length <= 0:
return string
return '\n'.join([string[i:i + max_length] for i in

View File

@ -122,7 +122,7 @@ class Client(client.HTTPClient):
"""
def __init__(self, **kwargs):
"""Initialize a new client for the Keystone v2.0 API. """
"""Initialize a new client for the Keystone v2.0 API."""
super(Client, self).__init__(**kwargs)
self.version = 'v2.0'
self.endpoints = endpoints.EndpointManager(self)

View File

@ -17,22 +17,22 @@ from keystoneclient import base
class Endpoint(base.Resource):
"""Represents a Keystone endpoint"""
"""Represents a Keystone endpoint."""
def __repr__(self):
return "<Endpoint %s>" % self._info
class EndpointManager(base.ManagerWithFind):
"""Manager class for manipulating Keystone endpoints"""
"""Manager class for manipulating Keystone endpoints."""
resource_class = Endpoint
def list(self):
"""List all available endpoints"""
"""List all available endpoints."""
return self._list('/endpoints', 'endpoints')
def create(self, region, service_id, publicurl, adminurl, internalurl):
"""Create a new endpoint"""
"""Create a new endpoint."""
body = {'endpoint': {'region': region,
'service_id': service_id,
'publicurl': publicurl,
@ -41,5 +41,5 @@ class EndpointManager(base.ManagerWithFind):
return self._create('/endpoints', body, 'endpoint')
def delete(self, id):
"""Delete an endpoint"""
"""Delete an endpoint."""
return self._delete('/endpoints/%s' % id)

View File

@ -18,7 +18,7 @@ from keystoneclient import base
class Role(base.Resource):
"""Represents a Keystone role"""
"""Represents a Keystone role."""
def __repr__(self):
return "<Role %s>" % self._info
@ -27,7 +27,7 @@ class Role(base.Resource):
class RoleManager(base.ManagerWithFind):
"""Manager class for manipulating Keystone roles"""
"""Manager class for manipulating Keystone roles."""
resource_class = Role
def get(self, role):

View File

@ -18,30 +18,30 @@ from keystoneclient import base
class Service(base.Resource):
"""Represents a Keystone service"""
"""Represents a Keystone service."""
def __repr__(self):
return "<Service %s>" % self._info
class ServiceManager(base.ManagerWithFind):
"""Manager class for manipulating Keystone services"""
"""Manager class for manipulating Keystone services."""
resource_class = Service
def list(self):
"""List available services"""
"""List available services."""
return self._list("/OS-KSADM/services", "OS-KSADM:services")
def get(self, id):
"""Retrieve a service by id"""
"""Retrieve a service by id."""
return self._get("/OS-KSADM/services/%s" % id, "OS-KSADM:service")
def create(self, name, service_type, description):
"""Create a new service"""
"""Create a new service."""
body = {"OS-KSADM:service": {'name': name,
'type': service_type,
'description': description}}
return self._create("/OS-KSADM/services", body, "OS-KSADM:service")
def delete(self, id):
"""Delete a service"""
"""Delete a service."""
return self._delete("/OS-KSADM/services/%s" % id)

View File

@ -46,7 +46,7 @@ def require_service_catalog(f):
help='Tenant; lists all users if not specified')
@utils.arg('--tenant_id', help=argparse.SUPPRESS)
def do_user_list(kc, args):
"""List users"""
"""List users."""
if args.tenant:
tenant_id = utils.find_resource(kc.tenants, args.tenant).id
else:
@ -96,7 +96,7 @@ def do_user_create(kc, args):
help='Enable or disable user')
@utils.arg('user', metavar='<user>', help='Name or ID of user to update')
def do_user_update(kc, args):
"""Update user's name, email, and enabled status"""
"""Update user's name, email, and enabled status."""
kwargs = {}
if args.name:
kwargs['name'] = args.name
@ -122,7 +122,7 @@ def do_user_update(kc, args):
@utils.arg('user', metavar='<user>',
help='Name or ID of user to update password')
def do_user_password_update(kc, args):
"""Update user password"""
"""Update user password."""
user = utils.find_resource(kc.users, args.user)
new_passwd = args.passwd or utils.prompt_for_password()
if new_passwd is None:
@ -139,7 +139,7 @@ def do_user_password_update(kc, args):
@utils.arg('--new-password ', metavar='<new-password>', dest='newpasswd',
required=False, help='Desired new password')
def do_password_update(kc, args):
"""Update own password"""
"""Update own password."""
# we are prompting for these passwords if they are not passed in
# this gives users the option not to have their password
@ -172,7 +172,7 @@ def do_user_delete(kc, args):
def do_tenant_list(kc, args):
"""List all tenants"""
"""List all tenants."""
tenants = kc.tenants.list()
utils.print_list(tenants, ['id', 'name', 'enabled'], order_by='name')
@ -180,7 +180,7 @@ def do_tenant_list(kc, args):
@utils.arg('tenant', metavar='<tenant>',
help='Name or ID of tenant to display')
def do_tenant_get(kc, args):
"""Display tenant details"""
"""Display tenant details."""
tenant = utils.find_resource(kc.tenants, args.tenant)
utils.print_dict(tenant._info)
@ -192,7 +192,7 @@ def do_tenant_get(kc, args):
@utils.arg('--enabled', metavar='<true|false>', default=True,
help='Initial tenant enabled status (default true)')
def do_tenant_create(kc, args):
"""Create new tenant"""
"""Create new tenant."""
tenant = kc.tenants.create(args.name,
description=args.description,
enabled=utils.string_to_bool(args.enabled))
@ -207,7 +207,7 @@ def do_tenant_create(kc, args):
help='Enable or disable tenant')
@utils.arg('tenant', metavar='<tenant>', help='Name or ID of tenant to update')
def do_tenant_update(kc, args):
"""Update tenant name, description, enabled status"""
"""Update tenant name, description, enabled status."""
tenant = utils.find_resource(kc.tenants, args.tenant)
kwargs = {}
if args.name:
@ -225,7 +225,7 @@ def do_tenant_update(kc, args):
@utils.arg('tenant', metavar='<tenant>', help='Name or ID of tenant to delete')
def do_tenant_delete(kc, args):
"""Delete tenant"""
"""Delete tenant."""
tenant = utils.find_resource(kc.tenants, args.tenant)
kc.tenants.delete(tenant)
@ -238,7 +238,7 @@ def do_tenant_delete(kc, args):
@utils.arg('--description', metavar='<service-description>',
help='Description of service')
def do_service_create(kc, args):
"""Add service to Service Catalog"""
"""Add service to Service Catalog."""
service = kc.services.create(args.name,
args.type,
args.description)
@ -246,7 +246,7 @@ def do_service_create(kc, args):
def do_service_list(kc, args):
"""List all services in Service Catalog"""
"""List all services in Service Catalog."""
services = kc.services.list()
utils.print_list(services, ['id', 'name', 'type', 'description'],
order_by='name')
@ -255,7 +255,7 @@ def do_service_list(kc, args):
@utils.arg('service', metavar='<service>',
help='Name or ID of service to display')
def do_service_get(kc, args):
"""Display service from Service Catalog"""
"""Display service from Service Catalog."""
service = utils.find_resource(kc.services, args.service)
utils.print_dict(service._info)
@ -263,20 +263,20 @@ def do_service_get(kc, args):
@utils.arg('service', metavar='<service>',
help='Name or ID of service to delete')
def do_service_delete(kc, args):
"""Delete service from Service Catalog"""
"""Delete service from Service Catalog."""
service = utils.find_resource(kc.services, args.service)
kc.services.delete(service.id)
def do_role_list(kc, args):
"""List all roles"""
"""List all roles."""
roles = kc.roles.list()
utils.print_list(roles, ['id', 'name'], order_by='name')
@utils.arg('role', metavar='<role>', help='Name or ID of role to display')
def do_role_get(kc, args):
"""Display role details"""
"""Display role details."""
role = utils.find_resource(kc.roles, args.role)
utils.print_dict(role._info)
@ -284,14 +284,14 @@ def do_role_get(kc, args):
@utils.arg('--name', metavar='<role-name>', required=True,
help='Name of new role')
def do_role_create(kc, args):
"""Create new role"""
"""Create new role."""
role = kc.roles.create(args.name)
utils.print_dict(role._info)
@utils.arg('role', metavar='<role>', help='Name or ID of role to delete')
def do_role_delete(kc, args):
"""Delete role"""
"""Delete role."""
role = utils.find_resource(kc.roles, args.role)
kc.roles.delete(role)
@ -375,7 +375,7 @@ def do_user_role_list(kc, args):
@utils.arg('--tenant-id', metavar='<tenant-id>', help='Tenant ID')
@utils.arg('--tenant_id', help=argparse.SUPPRESS)
def do_ec2_credentials_create(kc, args):
"""Create EC2-compatible credentials for user per tenant"""
"""Create EC2-compatible credentials for user per tenant."""
if not args.tenant_id:
# use the authenticated tenant id as a default
args.tenant_id = kc.auth_tenant_id
@ -391,7 +391,7 @@ def do_ec2_credentials_create(kc, args):
@utils.arg('--access', metavar='<access-key>', required=True,
help='Access Key')
def do_ec2_credentials_get(kc, args):
"""Display EC2-compatible credentials"""
"""Display EC2-compatible credentials."""
if not args.user_id:
# use the authenticated user id as a default
args.user_id = kc.auth_user_id
@ -423,7 +423,7 @@ def do_ec2_credentials_list(kc, args):
@utils.arg('--access', metavar='<access-key>', required=True,
help='Access Key')
def do_ec2_credentials_delete(kc, args):
"""Delete EC2-compatible credentials"""
"""Delete EC2-compatible credentials."""
if not args.user_id:
# use the authenticated user id as a default
args.user_id = kc.auth_user_id
@ -459,7 +459,7 @@ def do_catalog(kc, args):
help='Value of attribute to match')
@require_service_catalog
def do_endpoint_get(kc, args):
"""Find endpoint filtered by a specific attribute or service type"""
"""Find endpoint filtered by a specific attribute or service type."""
kwargs = {
'service_type': args.service,
'endpoint_type': args.endpoint_type,
@ -476,7 +476,7 @@ def do_endpoint_get(kc, args):
def do_endpoint_list(kc, args):
"""List configured service endpoints"""
"""List configured service endpoints."""
endpoints = kc.endpoints.list()
utils.print_list(endpoints,
['id', 'region', 'publicurl',
@ -495,7 +495,7 @@ def do_endpoint_list(kc, args):
@utils.arg('--internalurl', metavar='<internal-url>',
help='Internal URL endpoint')
def do_endpoint_create(kc, args):
"""Create a new endpoint associated with a service"""
"""Create a new endpoint associated with a service."""
service_id = utils.find_resource(kc.services, args.service).id
endpoint = kc.endpoints.create(args.region,
service_id,
@ -507,7 +507,7 @@ def do_endpoint_create(kc, args):
@utils.arg('id', metavar='<endpoint-id>', help='ID of endpoint to delete')
def do_endpoint_delete(kc, args):
"""Delete a service endpoint"""
"""Delete a service endpoint."""
try:
kc.endpoints.delete(args.id)
print('Endpoint has been deleted.')
@ -519,6 +519,6 @@ def do_endpoint_delete(kc, args):
help='wrap PKI tokens to a specified length, or 0 to disable')
@require_service_catalog
def do_token_get(kc, args):
"""Display the current user token"""
"""Display the current user token."""
utils.print_dict(kc.service_catalog.get_token(),
wrap=int(args.wrap))

View File

@ -68,7 +68,7 @@ class Tenant(base.Resource):
class TenantManager(base.ManagerWithFind):
"""Manager class for manipulating Keystone tenants"""
"""Manager class for manipulating Keystone tenants."""
resource_class = Tenant
def get(self, tenant_id):
@ -140,17 +140,17 @@ class TenantManager(base.ManagerWithFind):
return self._delete("/tenants/%s" % (base.getid(tenant)))
def list_users(self, tenant):
"""List users for a tenant. """
"""List users for a tenant."""
return self.api.users.list(base.getid(tenant))
def add_user(self, tenant, user, role):
"""Add a user to a tenant with the given role. """
"""Add a user to a tenant with the given role."""
return self.api.roles.add_user_role(base.getid(user),
base.getid(role),
base.getid(tenant))
def remove_user(self, tenant, user, role):
"""Remove the specified role from the user on the tenant. """
"""Remove the specified role from the user on the tenant."""
return self.api.roles.remove_user_role(base.getid(user),
base.getid(role),
base.getid(tenant))

View File

@ -32,7 +32,7 @@ class User(base.Resource):
class UserManager(base.ManagerWithFind):
"""Manager class for manipulating Keystone users"""
"""Manager class for manipulating Keystone users."""
resource_class = User
def get(self, user):

View File

@ -58,7 +58,7 @@ class Ec2SignerTest(testtools.TestCase):
self.assertFalse(self.signer._v4_creds(credentials))
def test_generate_0(self):
"""Test generate function for v0 signature"""
"""Test generate function for v0 signature."""
credentials = {'host': '127.0.0.1',
'verb': 'GET',
'path': '/v1/',
@ -71,7 +71,7 @@ class Ec2SignerTest(testtools.TestCase):
self.assertEqual(signature, expected)
def test_generate_1(self):
"""Test generate function for v1 signature"""
"""Test generate function for v1 signature."""
credentials = {'host': '127.0.0.1',
'verb': 'GET',
'path': '/v1/',
@ -82,7 +82,7 @@ class Ec2SignerTest(testtools.TestCase):
self.assertEqual(signature, expected)
def test_generate_v2_SHA256(self):
"""Test generate function for v2 signature, SHA256"""
"""Test generate function for v2 signature, SHA256."""
credentials = {'host': '127.0.0.1',
'verb': 'GET',
'path': '/v1/',
@ -93,7 +93,7 @@ class Ec2SignerTest(testtools.TestCase):
self.assertEqual(signature, expected)
def test_generate_v2_SHA1(self):
"""Test generate function for v2 signature, SHA1"""
"""Test generate function for v2 signature, SHA1."""
credentials = {'host': '127.0.0.1',
'verb': 'GET',
'path': '/v1/',

View File

@ -32,7 +32,7 @@ class KeyringTest(utils.TestCase):
'optional package keyring or pickle is not installed')
class MemoryKeyring(keyring.backend.KeyringBackend):
"""Simple memory keyring with support for multiple keys"""
"""Simple memory keyring with support for multiple keys."""
def __init__(self):
self.passwords = {}

View File

@ -185,7 +185,7 @@ class ShellTest(utils.TestCase):
self.assertTrue(all([x == y for x, y in zip(actual, expect)]))
def test_shell_user_create_args(self):
"""Test user-create args"""
"""Test user-create args."""
do_uc_mock = mock.MagicMock()
# grab the decorators for do_user_create
uc_func = getattr(shell_v2_0, 'do_user_create')

View File

@ -149,7 +149,7 @@ class TestCase(testtools.TestCase):
class UnauthenticatedTestCase(testtools.TestCase):
"""Class used as base for unauthenticated calls """
"""Class used as base for unauthenticated calls."""
TEST_ROOT_URL = 'http://127.0.0.1:5000/'
TEST_URL = '%s%s' % (TEST_ROOT_URL, 'v3')
TEST_ROOT_ADMIN_URL = 'http://127.0.0.1:35357/'

View File

@ -35,10 +35,9 @@ downloadcache = ~/cache/pip
# H302: import only modules
# H304: no relative imports
# H306: imports not in alphabetical order
# H402: one line docstring needs punctuation.
# H403: multi line docstring end on new line
# H404: multi line docstring should start with a summary
# H802: git commit title
ignore = F811,F821,F841,H201,H202,H302,H304,H306,H402,H403,H404,H802
ignore = F811,F821,F841,H201,H202,H302,H304,H306,H403,H404,H802
show-source = True
exclude = .venv,.tox,dist,doc,*egg,build