Spring cleaning, fix PEP8 violations.

Change-Id: Ide832cd64c9b285213e23901eaf81946d504e726
This commit is contained in:
Chmouel Boudjnah 2012-03-20 10:09:25 +00:00
parent 5ea232a09f
commit 3a296a458c
11 changed files with 104 additions and 100 deletions

View File

@ -3,7 +3,8 @@
# keystone documentation build configuration file, created by # keystone documentation build configuration file, created by
# sphinx-quickstart on Mon Jan 9 12:02:59 2012. # sphinx-quickstart on Mon Jan 9 12:02:59 2012.
# #
# This file is execfile()d with the current directory set to its containing dir. # This file is execfile()d with the current directory set to its
# containing dir.
# #
# Note that not all possible configuration values are present in this # Note that not all possible configuration values are present in this
# autogenerated file. # autogenerated file.
@ -19,14 +20,17 @@ import os
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../..')) sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ----------------------------------------------------- # -- General configuration
# -- -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0' #needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be extensions # Add any Sphinx extension module names here, as strings. They can be
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
#extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', 'sphinx.ext.coverage'] # ones.
#extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx',
# 'sphinx.ext.todo', 'sphinx.ext.coverage']
extensions = ['sphinx.ext.autodoc', extensions = ['sphinx.ext.autodoc',
'sphinx.ext.todo', 'sphinx.ext.todo',
# 'sphinx.ect.intersphinx', # 'sphinx.ect.intersphinx',
@ -77,7 +81,8 @@ release = '2012.1-dev'
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
exclude_patterns = [] exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all documents. # The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None #default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
@ -110,7 +115,7 @@ man_pages = [
] ]
# -- Options for HTML output --------------------------------------------------- # -- Options for HTML output
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
@ -193,7 +198,7 @@ html_last_updated_fmt = os.popen(git_cmd).read()
htmlhelp_basename = 'keystonedoc' htmlhelp_basename = 'keystonedoc'
# -- Options for LaTeX output -------------------------------------------------- # -- Options for LaTeX output
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
@ -206,8 +211,9 @@ latex_elements = {
#'preamble': '', #'preamble': '',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples (source
# (source start file, target name, title, author, documentclass [howto/manual]). # start file, target name, title, author, documentclass
# [howto/manual]).
latex_documents = [ latex_documents = [
('index', 'keystone.tex', u'Keystone Documentation', ('index', 'keystone.tex', u'Keystone Documentation',
u'OpenStack', 'manual'), u'OpenStack', 'manual'),
@ -234,20 +240,19 @@ latex_documents = [
#latex_domain_indices = True #latex_domain_indices = True
# -- Options for manual page output -------------------------------------------- # -- Options for manual page output
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
('index', 'keystone', u'Keystone Documentation', ('index', 'keystone', u'Keystone Documentation',
[u'OpenStack'], 1) [u'OpenStack'], 1)]
]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False #man_show_urls = False
# -- Options for Texinfo output ------------------------------------------------ # -- Options for Texinfo output
# Grouping the document tree into Texinfo files. List of tuples # Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author, # (source start file, target name, title, author,

1
run_tests.py Normal file → Executable file
View File

@ -69,7 +69,6 @@ from nose import core
from nose import result from nose import result
class _AnsiColorizer(object): class _AnsiColorizer(object):
""" """
A colorizer is an object that loosely wraps around a stream, allowing A colorizer is an object that loosely wraps around a stream, allowing

View File

@ -22,12 +22,12 @@ TENANTS = [
# NOTE(ja): a role of keystone_admin and attribute "is_admin" is done in setUp # NOTE(ja): a role of keystone_admin and attribute "is_admin" is done in setUp
USERS = [ USERS = [
{'id': 'foo', 'name': 'FOO', 'password': 'foo2', 'tenants': ['bar',]}, {'id': 'foo', 'name': 'FOO', 'password': 'foo2', 'tenants': ['bar']},
{'id': 'two', 'name': 'TWO', 'password': 'two2', 'tenants': ['baz',]}, {'id': 'two', 'name': 'TWO', 'password': 'two2', 'tenants': ['baz']},
{'id': 'no_meta', {'id': 'no_meta',
'name': 'NO_META', 'name': 'NO_META',
'password': 'no_meta2', 'password': 'no_meta2',
'tenants': ['baz',]}, 'tenants': ['baz']},
] ]
METADATA = [ METADATA = [

View File

@ -169,10 +169,9 @@ class FakeHTTPConnection(object):
def close(self): def close(self):
pass pass
class FakeApp(object):
"""This represents a WSGI app protected by the auth_token middleware.
""" class FakeApp(object):
"""This represents a WSGI app protected by the auth_token middleware."""
def __init__(self, expected_env=None): def __init__(self, expected_env=None):
expected_env = expected_env or {} expected_env = expected_env or {}
self.expected_env = { self.expected_env = {
@ -238,6 +237,7 @@ class DiabloAuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest):
self.assertEqual(self.response_status, 200) self.assertEqual(self.response_status, 200)
self.assertEqual(body, ['SUCCESS']) self.assertEqual(body, ['SUCCESS'])
class AuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest): class AuthTokenMiddlewareTest(BaseAuthTokenMiddlewareTest):
def test_valid_request(self): def test_valid_request(self):
req = webob.Request.blank('/') req = webob.Request.blank('/')

View File

@ -46,9 +46,9 @@ class IdentityTests(object):
user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate( user_ref, tenant_ref, metadata_ref = self.identity_api.authenticate(
user_id=self.user_foo['id'], user_id=self.user_foo['id'],
password=self.user_foo['password']) password=self.user_foo['password'])
# NOTE(termie): the password field is left in user_foo to make it easier # NOTE(termie): the password field is left in user_foo to make
# to authenticate in tests, but should not be returned by # it easier to authenticate in tests, but should
# the api # not be returned by the api
self.user_foo.pop('password') self.user_foo.pop('password')
self.assertDictEquals(user_ref, self.user_foo) self.assertDictEquals(user_ref, self.user_foo)
self.assert_(tenant_ref is None) self.assert_(tenant_ref is None)
@ -59,9 +59,9 @@ class IdentityTests(object):
user_id=self.user_foo['id'], user_id=self.user_foo['id'],
tenant_id=self.tenant_bar['id'], tenant_id=self.tenant_bar['id'],
password=self.user_foo['password']) password=self.user_foo['password'])
# NOTE(termie): the password field is left in user_foo to make it easier # NOTE(termie): the password field is left in user_foo to make
# to authenticate in tests, but should not be returned by # it easier to authenticate in tests, but should
# the api # not be returned by the api
self.user_foo.pop('password') self.user_foo.pop('password')
self.assertDictEquals(user_ref, self.user_foo) self.assertDictEquals(user_ref, self.user_foo)
self.assertDictEquals(tenant_ref, self.tenant_bar) self.assertDictEquals(tenant_ref, self.tenant_bar)
@ -74,9 +74,9 @@ class IdentityTests(object):
user_id=user['id'], user_id=user['id'],
tenant_id=tenant['id'], tenant_id=tenant['id'],
password=user['password']) password=user['password'])
# NOTE(termie): the password field is left in user_foo to make it easier # NOTE(termie): the password field is left in user_foo to make
# to authenticate in tests, but should not be returned by # it easier to authenticate in tests, but should
# the api # not be returned by the api
user.pop('password') user.pop('password')
self.assertEquals(metadata_ref, {}) self.assertEquals(metadata_ref, {})
self.assertDictEquals(user_ref, user) self.assertDictEquals(user_ref, user)
@ -113,18 +113,18 @@ class IdentityTests(object):
def test_get_user(self): def test_get_user(self):
user_ref = self.identity_api.get_user(user_id=self.user_foo['id']) user_ref = self.identity_api.get_user(user_id=self.user_foo['id'])
# NOTE(termie): the password field is left in user_foo to make it easier # NOTE(termie): the password field is left in user_foo to make
# to authenticate in tests, but should not be returned by # it easier to authenticate in tests, but should
# the api # not be returned by the api
self.user_foo.pop('password') self.user_foo.pop('password')
self.assertDictEquals(user_ref, self.user_foo) self.assertDictEquals(user_ref, self.user_foo)
def test_get_user_by_name(self): def test_get_user_by_name(self):
user_ref = self.identity_api.get_user_by_name( user_ref = self.identity_api.get_user_by_name(
user_name=self.user_foo['name']) user_name=self.user_foo['name'])
# NOTE(termie): the password field is left in user_foo to make it easier # NOTE(termie): the password field is left in user_foo to make
# to authenticate in tests, but should not be returned by # it easier to authenticate in tests, but should
# the api # not be returned by the api
self.user_foo.pop('password') self.user_foo.pop('password')
self.assertDictEquals(user_ref, self.user_foo) self.assertDictEquals(user_ref, self.user_foo)
@ -155,7 +155,7 @@ class IdentityTests(object):
user = {'id': 'fake1', user = {'id': 'fake1',
'name': 'fake1', 'name': 'fake1',
'password': 'fakepass', 'password': 'fakepass',
'tenants': ['bar',]} 'tenants': ['bar']}
self.identity_api.create_user('fake1', user) self.identity_api.create_user('fake1', user)
user['name'] = 'fake2' user['name'] = 'fake2'
self.assertRaises(Exception, self.assertRaises(Exception,
@ -167,7 +167,7 @@ class IdentityTests(object):
user = {'id': 'fake1', user = {'id': 'fake1',
'name': 'fake1', 'name': 'fake1',
'password': 'fakepass', 'password': 'fakepass',
'tenants': ['bar',]} 'tenants': ['bar']}
self.identity_api.create_user('fake1', user) self.identity_api.create_user('fake1', user)
user['id'] = 'fake2' user['id'] = 'fake2'
self.assertRaises(Exception, self.assertRaises(Exception,
@ -179,11 +179,11 @@ class IdentityTests(object):
user1 = {'id': 'fake1', user1 = {'id': 'fake1',
'name': 'fake1', 'name': 'fake1',
'password': 'fakepass', 'password': 'fakepass',
'tenants': ['bar',]} 'tenants': ['bar']}
user2 = {'id': 'fake2', user2 = {'id': 'fake2',
'name': 'fake2', 'name': 'fake2',
'password': 'fakepass', 'password': 'fakepass',
'tenants': ['bar',]} 'tenants': ['bar']}
self.identity_api.create_user('fake1', user1) self.identity_api.create_user('fake1', user1)
self.identity_api.create_user('fake2', user2) self.identity_api.create_user('fake2', user2)
user2['name'] = 'fake1' user2['name'] = 'fake1'
@ -196,7 +196,7 @@ class IdentityTests(object):
user = {'id': 'fake1', user = {'id': 'fake1',
'name': 'fake1', 'name': 'fake1',
'password': 'fakepass', 'password': 'fakepass',
'tenants': ['bar',]} 'tenants': ['bar']}
self.identity_api.create_user('fake1', user) self.identity_api.create_user('fake1', user)
user['id'] = 'fake2' user['id'] = 'fake2'
self.identity_api.update_user('fake1', user) self.identity_api.update_user('fake1', user)
@ -244,29 +244,28 @@ class IdentityTests(object):
tenant_ref = self.identity_api.get_tenant('fake2') tenant_ref = self.identity_api.get_tenant('fake2')
self.assert_(tenant_ref is None) self.assert_(tenant_ref is None)
def test_get_role_by_user_and_tenant(self): def test_get_role_by_user_and_tenant(self):
roles_ref = self.identity_api.get_roles_for_user_and_tenant( roles_ref = self.identity_api.get_roles_for_user_and_tenant(
self.user_foo['id'],self.tenant_bar['id']) self.user_foo['id'], self.tenant_bar['id'])
self.assertNotIn('keystone_admin', roles_ref) self.assertNotIn('keystone_admin', roles_ref)
self.identity_api.add_role_to_user_and_tenant( self.identity_api.add_role_to_user_and_tenant(
self.user_foo['id'],self.tenant_bar['id'], 'keystone_admin') self.user_foo['id'], self.tenant_bar['id'], 'keystone_admin')
roles_ref = self.identity_api.get_roles_for_user_and_tenant( roles_ref = self.identity_api.get_roles_for_user_and_tenant(
self.user_foo['id'],self.tenant_bar['id']) self.user_foo['id'], self.tenant_bar['id'])
self.assertIn('keystone_admin', roles_ref) self.assertIn('keystone_admin', roles_ref)
self.assertNotIn('useless',roles_ref) self.assertNotIn('useless', roles_ref)
self.identity_api.add_role_to_user_and_tenant( self.identity_api.add_role_to_user_and_tenant(
self.user_foo['id'],self.tenant_bar['id'], 'useless') self.user_foo['id'], self.tenant_bar['id'], 'useless')
roles_ref = self.identity_api.get_roles_for_user_and_tenant( roles_ref = self.identity_api.get_roles_for_user_and_tenant(
self.user_foo['id'],self.tenant_bar['id']) self.user_foo['id'], self.tenant_bar['id'])
self.assertIn('keystone_admin', roles_ref) self.assertIn('keystone_admin', roles_ref)
self.assertIn('useless',roles_ref) self.assertIn('useless', roles_ref)
def test_delete_role(self): def test_delete_role(self):
role_id = 'test_role_delete' role_id = 'test_role_delete'
new_role = {'id': role_id, 'name': 'Role to Delete'} new_role = {'id': role_id, 'name': 'Role to Delete'}
self.identity_api.create_role(role_id , new_role) self.identity_api.create_role(role_id, new_role)
role_ref = self.identity_api.get_role(role_id) role_ref = self.identity_api.get_role(role_id)
self.assertDictEquals(role_ref, new_role) self.assertDictEquals(role_ref, new_role)
self.identity_api.delete_role(role_id) self.identity_api.delete_role(role_id)
@ -277,7 +276,7 @@ class IdentityTests(object):
def test_add_user_to_tenant(self): def test_add_user_to_tenant(self):
tenant_id = 'tenent4add' tenant_id = 'tenent4add'
self.identity_api.add_user_to_tenant(tenant_id, 'foo') self.identity_api.add_user_to_tenant(tenant_id, 'foo')
tenants = self.identity_api.get_tenants_for_user('foo') tenants = self.identity_api.get_tenants_for_user('foo')
self.assertIn(tenant_id, tenants) self.assertIn(tenant_id, tenants)
@ -303,7 +302,7 @@ class TokenTests(object):
def test_expired_token(self): def test_expired_token(self):
token_id = uuid.uuid4().hex token_id = uuid.uuid4().hex
expire_time = datetime.datetime.now() - datetime.timedelta(minutes=1) expire_time = datetime.datetime.now() - datetime.timedelta(minutes=1)
data = {'id': token_id, 'a': 'b', 'expires': expire_time} data = {'id': token_id, 'a': 'b', 'expires': expire_time}
data_ref = self.token_api.create_token(token_id, data) data_ref = self.token_api.create_token(token_id, data)
self.assertDictEquals(data_ref, data) self.assertDictEquals(data_ref, data)

View File

@ -23,38 +23,38 @@ import default_fixtures
class KvsIdentity(test.TestCase, test_backend.IdentityTests): class KvsIdentity(test.TestCase, test_backend.IdentityTests):
def setUp(self): def setUp(self):
super(KvsIdentity, self).setUp() super(KvsIdentity, self).setUp()
self.identity_api = identity_kvs.Identity(db={}) self.identity_api = identity_kvs.Identity(db={})
self.load_fixtures(default_fixtures) self.load_fixtures(default_fixtures)
class KvsToken(test.TestCase, test_backend.TokenTests): class KvsToken(test.TestCase, test_backend.TokenTests):
def setUp(self): def setUp(self):
super(KvsToken, self).setUp() super(KvsToken, self).setUp()
self.token_api = token_kvs.Token(db={}) self.token_api = token_kvs.Token(db={})
class KvsCatalog(test.TestCase, test_backend.CatalogTests): class KvsCatalog(test.TestCase, test_backend.CatalogTests):
def setUp(self): def setUp(self):
super(KvsCatalog, self).setUp() super(KvsCatalog, self).setUp()
self.catalog_api = catalog_kvs.Catalog(db={}) self.catalog_api = catalog_kvs.Catalog(db={})
self.load_fixtures(default_fixtures) self.load_fixtures(default_fixtures)
self._load_fake_catalog() self._load_fake_catalog()
def _load_fake_catalog(self): def _load_fake_catalog(self):
self.catalog_foobar = self.catalog_api._create_catalog( self.catalog_foobar = self.catalog_api._create_catalog(
'foo', 'bar', 'foo', 'bar',
{'RegionFoo': {'service_bar': {'foo': 'bar'}}}) {'RegionFoo': {'service_bar': {'foo': 'bar'}}})
def test_get_catalog_bad_user(self): def test_get_catalog_bad_user(self):
catalog_ref = self.catalog_api.get_catalog('foo' + 'WRONG', 'bar') catalog_ref = self.catalog_api.get_catalog('foo' + 'WRONG', 'bar')
self.assert_(catalog_ref is None) self.assert_(catalog_ref is None)
def test_get_catalog_bad_tenant(self): def test_get_catalog_bad_tenant(self):
catalog_ref = self.catalog_api.get_catalog('foo', 'bar' + 'WRONG') catalog_ref = self.catalog_api.get_catalog('foo', 'bar' + 'WRONG')
self.assert_(catalog_ref is None) self.assert_(catalog_ref is None)
def test_get_catalog(self): def test_get_catalog(self):
catalog_ref = self.catalog_api.get_catalog('foo', 'bar') catalog_ref = self.catalog_api.get_catalog('foo', 'bar')
self.assertDictEquals(catalog_ref, self.catalog_foobar) self.assertDictEquals(catalog_ref, self.catalog_foobar)

View File

@ -28,24 +28,24 @@ CONF = config.CONF
class SqlIdentity(test.TestCase, test_backend.IdentityTests): class SqlIdentity(test.TestCase, test_backend.IdentityTests):
def setUp(self): def setUp(self):
super(SqlIdentity, self).setUp() super(SqlIdentity, self).setUp()
CONF(config_files=[test.etcdir('keystone.conf'), CONF(config_files=[test.etcdir('keystone.conf'),
test.testsdir('test_overrides.conf'), test.testsdir('test_overrides.conf'),
test.testsdir('backend_sql.conf')]) test.testsdir('backend_sql.conf')])
sql_util.setup_test_database() sql_util.setup_test_database()
self.identity_api = identity_sql.Identity() self.identity_api = identity_sql.Identity()
self.load_fixtures(default_fixtures) self.load_fixtures(default_fixtures)
class SqlToken(test.TestCase, test_backend.TokenTests): class SqlToken(test.TestCase, test_backend.TokenTests):
def setUp(self): def setUp(self):
super(SqlToken, self).setUp() super(SqlToken, self).setUp()
CONF(config_files=[test.etcdir('keystone.conf'), CONF(config_files=[test.etcdir('keystone.conf'),
test.testsdir('test_overrides.conf'), test.testsdir('test_overrides.conf'),
test.testsdir('backend_sql.conf')]) test.testsdir('backend_sql.conf')])
sql_util.setup_test_database() sql_util.setup_test_database()
self.token_api = token_sql.Token() self.token_api = token_sql.Token()
#class SqlCatalog(test_backend_kvs.KvsCatalog): #class SqlCatalog(test_backend_kvs.KvsCatalog):

View File

@ -368,9 +368,9 @@ class CoreApiTests(object):
def test_validate_token_belongs_to(self): def test_validate_token_belongs_to(self):
token = self.get_scoped_token() token = self.get_scoped_token()
path = ('/v2.0/tokens/%s?belongsTo=%s' path = ('/v2.0/tokens/%s?belongsTo=%s' % (token,
% (token, self.tenant_bar['id'])) self.tenant_bar['id']))
r = self.admin_request(path=path,token=token) r = self.admin_request(path=path, token=token)
self.assertValidAuthenticationResponse(r, self.assertValidAuthenticationResponse(r,
require_service_catalog=True) require_service_catalog=True)

View File

@ -24,11 +24,9 @@ from keystone import test
from keystone.common.sql import legacy from keystone.common.sql import legacy
from keystone.common.sql import util as sql_util from keystone.common.sql import util as sql_util
from keystone.identity.backends import sql as identity_sql from keystone.identity.backends import sql as identity_sql
from keystone.token.backends import sql as token_sql
from keystone.catalog.backends import templated as catalog_templated from keystone.catalog.backends import templated as catalog_templated
CONF = config.CONF CONF = config.CONF

View File

@ -510,7 +510,8 @@ class KcMasterTestCase(CompatTestCase, KeystoneClientTests):
tenant_id = uuid.uuid4().hex tenant_id = uuid.uuid4().hex
tenant = {'name': 'tenant-%s' % tenant_id, 'id': tenant_id} tenant = {'name': 'tenant-%s' % tenant_id, 'id': tenant_id}
self.identity_api.create_tenant(tenant_id, tenant) self.identity_api.create_tenant(tenant_id, tenant)
self.identity_api.add_user_to_tenant(tenant_id, self.user_foo['id']) self.identity_api.add_user_to_tenant(tenant_id,
self.user_foo['id'])
tenants = client.tenants.list() tenants = client.tenants.list()
self.assertEqual(len(tenants), 3) self.assertEqual(len(tenants), 3)
@ -535,7 +536,8 @@ class KcMasterTestCase(CompatTestCase, KeystoneClientTests):
tenant_id = uuid.uuid4().hex tenant_id = uuid.uuid4().hex
tenant = {'name': 'tenant-%s' % tenant_id, 'id': tenant_id} tenant = {'name': 'tenant-%s' % tenant_id, 'id': tenant_id}
self.identity_api.create_tenant(tenant_id, tenant) self.identity_api.create_tenant(tenant_id, tenant)
self.identity_api.add_user_to_tenant(tenant_id, self.user_foo['id']) self.identity_api.add_user_to_tenant(tenant_id,
self.user_foo['id'])
tenants = client.tenants.list() tenants = client.tenants.list()
self.assertEqual(len(tenants), 3) self.assertEqual(len(tenants), 3)

View File

@ -95,7 +95,8 @@ class JsonBodyMiddlewareTest(test.TestCase):
_middleware.process_request, req) _middleware.process_request, req)
def test_no_content_type(self): def test_no_content_type(self):
req = make_request(body='{"arg1": "one", "arg2": ["a"]}', method='POST') req = make_request(body='{"arg1": "one", "arg2": ["a"]}',
method='POST')
middleware.JsonBodyMiddleware(None).process_request(req) middleware.JsonBodyMiddleware(None).process_request(req)
params = req.environ[middleware.PARAMS_ENV] params = req.environ[middleware.PARAMS_ENV]
self.assertEqual(params, {"arg1": "one", "arg2": ["a"]}) self.assertEqual(params, {"arg1": "one", "arg2": ["a"]})