Update keystoneclient code to account for hacking 0.9.2

Fixed most of the errors reported back from hacking 0.9.2.
Specifically:
- E128 continuation line under-indented for visual indent
- E251 unexpected spaces around keyword / parameter equals
- E265 block comment should start with '# '
- H305 imports not grouped correctly
- H307 like imports should be grouped together
- H402 one line docstring needs punctuation
- H904 Wrap long lines in parentheses instead of a backslash

But opted to ignore the following for now:
- E122: continuation line missing indentation or outdented
- H405: multi line docstring summary not separated with an empty line

Change-Id: Ib8e698d85fd598fa91435538657361a1f695ce89
This commit is contained in:
Steve Martinelli
2014-06-16 02:08:59 -04:00
parent b2a0c5bc82
commit 1c64e5c1f7
16 changed files with 63 additions and 57 deletions

View File

@@ -11,6 +11,7 @@
# under the License.
import abc
import six

View File

@@ -12,6 +12,7 @@
import abc
import logging
import six
from keystoneclient.auth import base

View File

@@ -24,8 +24,9 @@ import logging
from six.moves.urllib import parse as urlparse
try:
import keyring
import pickle
import keyring
except ImportError:
keyring = None
pickle = None

View File

@@ -149,13 +149,13 @@ import contextlib
import datetime
import logging
import os
import requests
import stat
import tempfile
import time
import netaddr
from oslo.config import cfg
import requests
import six
from six.moves import urllib

View File

@@ -33,9 +33,10 @@ import hashlib
import hmac
import math
import os
import six
import sys
import six
# make sure pycrypto is available
try:
from Crypto.Cipher import AES

View File

@@ -32,11 +32,11 @@ This WSGI component:
"""
import logging
import webob
import requests
import six
from six.moves import urllib
import webob
from keystoneclient.openstack.common import jsonutils

View File

@@ -637,7 +637,7 @@ class CommonAuthTokenMiddlewareTest(object):
for _ in range(2): # Do it twice because first result was cached.
self.assert_valid_request_200(
self.token_dict['signed_token_scoped'])
#ensure that signed requests do not generate HTTP traffic
# ensure that signed requests do not generate HTTP traffic
self.assertLastPath(None)
def test_valid_signed_compressed_request(self):
@@ -722,7 +722,7 @@ class CommonAuthTokenMiddlewareTest(object):
return jsonutils.dumps(revocation_list)
def test_is_signed_token_revoked_returns_false(self):
#explicitly setting an empty revocation list here to document intent
# explicitly setting an empty revocation list here to document intent
self.middleware.token_revocation_list = jsonutils.dumps(
{"revoked": [], "extra": "success"})
result = self.middleware.is_signed_token_revoked(
@@ -1443,10 +1443,10 @@ class v2AuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
self.examples.UUID_TOKEN_UNKNOWN_BIND,
self.examples.UUID_TOKEN_NO_SERVICE_CATALOG,
self.examples.SIGNED_TOKEN_SCOPED_KEY,):
response_body = self.examples.JSON_TOKEN_RESPONSES[token]
httpretty.register_uri(httpretty.GET,
"%s/v2.0/tokens/%s" % (BASE_URI, token),
body=
self.examples.JSON_TOKEN_RESPONSES[token])
body=response_body)
httpretty.register_uri(httpretty.GET,
'%s/v2.0/tokens/%s' % (BASE_URI, ERROR_TOKEN),
@@ -1537,10 +1537,10 @@ class CrossVersionAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest,
body=FAKE_ADMIN_TOKEN)
token = self.examples.UUID_TOKEN_DEFAULT
response_body = self.examples.JSON_TOKEN_RESPONSES[token]
httpretty.register_uri(httpretty.GET,
"%s/v2.0/tokens/%s" % (BASE_URI, token),
body=
self.examples.JSON_TOKEN_RESPONSES[token])
body=response_body)
self.set_middleware(conf=conf)

View File

@@ -90,8 +90,8 @@ class KeyringTest(utils.TestCase):
tenant_id=TENANT_ID, auth_url=AUTH_URL)
# stub and check that a new token is received
with mock.patch.object(cl, 'get_raw_token_from_identity_service') \
as meth:
method = 'get_raw_token_from_identity_service'
with mock.patch.object(cl, method) as meth:
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
self.assertTrue(cl.authenticate())
@@ -128,8 +128,8 @@ class KeyringTest(utils.TestCase):
self.memory_keyring.password = pickle.dumps(auth_ref)
# stub and check that a new token is received, so not using expired
with mock.patch.object(cl, 'get_raw_token_from_identity_service') \
as meth:
method = 'get_raw_token_from_identity_service'
with mock.patch.object(cl, method) as meth:
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
self.assertTrue(cl.authenticate())
@@ -166,8 +166,8 @@ class KeyringTest(utils.TestCase):
use_keyring=True)
# stub and check that a new token is received
with mock.patch.object(cl, 'get_raw_token_from_identity_service') \
as meth:
method = 'get_raw_token_from_identity_service'
with mock.patch.object(cl, method) as meth:
meth.return_value = (True, PROJECT_SCOPED_TOKEN)
self.assertTrue(cl.authenticate())

View File

@@ -313,9 +313,9 @@ class ShellTest(utils.TestCase):
shell('tenant-create')
assert do_tenant_mock.called
# FIXME(dtroyer): how do you test the decorators?
#shell('tenant-create --tenant-name wilma '
# shell('tenant-create --tenant-name wilma '
# '--description "fred\'s wife"')
#assert do_tenant_mock.called
# assert do_tenant_mock.called
def test_do_tenant_list(self):
do_tenant_mock = mock.MagicMock()

View File

@@ -13,6 +13,7 @@
import logging
import sys
import time
import uuid
import fixtures
import httpretty
@@ -22,7 +23,6 @@ import requests
import six
from six.moves.urllib import parse as urlparse
import testtools
import uuid
from keystoneclient.openstack.common import jsonutils

View File

@@ -218,18 +218,18 @@ class FakeHTTPClient(fakes.FakeClient):
def post_tenants(self, **kw):
body = {"tenant":
{"enabled": True,
"description": None,
"name": "new-tenant",
"id": "1"}}
{"enabled": True,
"description": None,
"name": "new-tenant",
"id": "1"}}
return (200, body)
def post_tenants_2(self, **kw):
body = {"tenant":
{"enabled": False,
"description": "desc",
"name": "new-tenant1",
"id": "2"}}
{"enabled": False,
"description": "desc",
"name": "new-tenant1",
"id": "2"}}
return (200, body)
def get_tenants(self, **kw):
@@ -253,18 +253,18 @@ class FakeHTTPClient(fakes.FakeClient):
def get_tenants_1(self, **kw):
body = {"tenant":
{"enabled": True,
"description": None,
"name": "new-tenant",
"id": "1"}}
{"enabled": True,
"description": None,
"name": "new-tenant",
"id": "1"}}
return (200, body)
def get_tenants_2(self, **kw):
body = {"tenant":
{"enabled": True,
"description": None,
"name": "new-tenant",
"id": "2"}}
{"enabled": True,
"description": None,
"name": "new-tenant",
"id": "2"}}
return (200, body)
def delete_tenants_2(self, **kw):
@@ -375,8 +375,8 @@ class FakeHTTPClient(fakes.FakeClient):
def post_OS_KSADM_roles(self, **kw):
body = {"role":
{"name": "new-role",
"id": "1"}}
{"name": "new-role",
"id": "1"}}
return (200, body)
def get_OS_KSADM_roles(self, **kw):
@@ -389,8 +389,8 @@ class FakeHTTPClient(fakes.FakeClient):
def get_OS_KSADM_roles_1(self, **kw):
body = {"role":
{"name": "new-role",
"id": "1"}
{"name": "new-role",
"id": "1"}
}
return (200, body)
@@ -400,19 +400,19 @@ class FakeHTTPClient(fakes.FakeClient):
def post_OS_KSADM_services(self, **kw):
body = {"OS-KSADM:service":
{"id": "1",
"type": "compute",
"name": "service1",
"description": None}
{"id": "1",
"type": "compute",
"name": "service1",
"description": None}
}
return (200, body)
def get_OS_KSADM_services_1(self, **kw):
body = {"OS-KSADM:service":
{"description": None,
"type": "compute",
"id": "1",
"name": "service1"}
{"description": None,
"type": "compute",
"id": "1",
"name": "service1"}
}
return (200, body)
@@ -436,10 +436,10 @@ class FakeHTTPClient(fakes.FakeClient):
def post_users_1_credentials_OS_EC2(self, **kw):
body = {"credential":
{"access": "1",
"tenant_id": "1",
"secret": "1",
"user_id": "1"}
{"access": "1",
"tenant_id": "1",
"secret": "1",
"user_id": "1"}
}
return (200, body)

View File

@@ -176,7 +176,7 @@ class TenantTests(utils.TestCase):
"description": "I changed you!",
"enabled": False,
"extravalue01": "metadataChanged",
#"extraname": "dontoverwrite!",
# "extraname": "dontoverwrite!",
},
}
resp_body = {

View File

@@ -87,7 +87,7 @@ def do_user_get(kc, args):
@utils.arg('--enabled', metavar='<true|false>', default=True,
help='Initial user enabled status. Default is true.')
def do_user_create(kc, args):
"""Create new user"""
"""Create new user."""
if args.tenant:
tenant_id = utils.find_resource(kc.tenants, args.tenant).id
elif args.tenant_id:

View File

@@ -81,7 +81,7 @@ class TenantManager(base.ManagerWithFind):
"description": description,
"enabled": enabled}}
#Allow Extras Passthru and ensure we don't clobber primary arguments.
# Allow Extras Passthru and ensure we don't clobber primary arguments.
for k, v in six.iteritems(kwargs):
if k not in params['tenant']:
params['tenant'][k] = v
@@ -131,7 +131,7 @@ class TenantManager(base.ManagerWithFind):
if description is not None:
body['tenant']['description'] = description
#Allow Extras Passthru and ensure we don't clobber primary arguments.
# Allow Extras Passthru and ensure we don't clobber primary arguments.
for k, v in six.iteritems(kwargs):
if k not in body['tenant']:
body['tenant'][k] = v

View File

@@ -20,7 +20,7 @@ from keystoneclient import base
class User(base.Resource):
"""Represents a Keystone user"""
"""Represents a Keystone user."""
def __repr__(self):
return "<User %s>" % self._info

View File

@@ -36,7 +36,9 @@ commands =
# F821: undefined name
# H304: no relative imports
# H803 Commit message should not end with a period (do not remove per list discussion)
ignore = F821,H304,H803
# H405: multi line docstring summary not separated with an empty line
# E122: continuation line missing indentation or outdented
ignore = F821,H304,H803,H405,E122
show-source = True
exclude = .venv,.tox,dist,doc,*egg,build,*openstack/common*