Clean up pep8 E124 violations

Fixed E124 errors
All other ignores are to be removed in the next sequence of patches

Change-Id: Ic96ebf5dff645dfdc47478beeb6965d6ad266243
This commit is contained in:
Zhongyue Luo 2012-09-19 17:01:13 +08:00
parent 8a8b01174c
commit 305a9c12b5
12 changed files with 100 additions and 85 deletions

View File

@ -29,8 +29,7 @@ from webob.exc import (HTTPError,
HTTPBadRequest, HTTPBadRequest,
HTTPForbidden, HTTPForbidden,
HTTPRequestEntityTooLarge, HTTPRequestEntityTooLarge,
HTTPServiceUnavailable, HTTPServiceUnavailable)
)
from glance.api import common from glance.api import common
from glance.api import policy from glance.api import policy

View File

@ -45,15 +45,16 @@ class RequestContext(object):
def to_dict(self): def to_dict(self):
# NOTE(ameade): These keys are named to correspond with the default # NOTE(ameade): These keys are named to correspond with the default
# format string for logging the context in openstack common # format string for logging the context in openstack common
return {'request_id': self.request_id, return {
'user_id': self.user, 'request_id': self.request_id,
'tenant_id': self.tenant, 'user_id': self.user,
'is_admin': self.is_admin, 'tenant_id': self.tenant,
'project_id': self.tenant, 'is_admin': self.is_admin,
'read_deleted': self.show_deleted, 'project_id': self.tenant,
'roles': self.roles, 'read_deleted': self.show_deleted,
'auth_token': self.auth_tok, 'roles': self.roles,
'service_catalog': self.service_catalog, 'auth_token': self.auth_tok,
'service_catalog': self.service_catalog,
} }
@classmethod @classmethod

View File

@ -107,8 +107,7 @@ def get_client(host, port=None, timeout=None, use_ssl=False, username=None,
auth_url=auth_url or os.getenv('OS_AUTH_URL'), auth_url=auth_url or os.getenv('OS_AUTH_URL'),
strategy=force_strategy or auth_strategy or strategy=force_strategy or auth_strategy or
os.getenv('OS_AUTH_STRATEGY', 'noauth'), os.getenv('OS_AUTH_STRATEGY', 'noauth'),
region=region or os.getenv('OS_REGION_NAME'), region=region or os.getenv('OS_REGION_NAME'))
)
if creds['strategy'] == 'keystone' and not creds['auth_url']: if creds['strategy'] == 'keystone' and not creds['auth_url']:
msg = ("--os_auth_url option or OS_AUTH_URL environment variable " msg = ("--os_auth_url option or OS_AUTH_URL environment variable "

View File

@ -30,12 +30,13 @@ LOG = logging.getLogger(__name__)
store_opts = [ store_opts = [
cfg.ListOpt('known_stores', cfg.ListOpt('known_stores',
default=['glance.store.filesystem.Store', default=[
'glance.store.http.Store', 'glance.store.filesystem.Store',
'glance.store.rbd.Store', 'glance.store.http.Store',
'glance.store.s3.Store', 'glance.store.rbd.Store',
'glance.store.swift.Store', 'glance.store.s3.Store',
]), 'glance.store.swift.Store',
]),
cfg.StrOpt('scrubber_datadir', cfg.StrOpt('scrubber_datadir',
default='/var/lib/glance/scrubber'), default='/var/lib/glance/scrubber'),
cfg.BoolOpt('delayed_delete', default=False), cfg.BoolOpt('delayed_delete', default=False),

View File

@ -269,9 +269,10 @@ class BaseTestCase(object):
def test_image_get_all_size_min_max(self): def test_image_get_all_size_min_max(self):
images = self.db_api.image_get_all(self.context, images = self.db_api.image_get_all(self.context,
filters={'size_min': 10, filters={
'size_min': 10,
'size_max': 15, 'size_max': 15,
}) })
self.assertEquals(len(images), 1) self.assertEquals(len(images), 1)
self.assertEquals(images[0]['id'], self.fixtures[0]['id']) self.assertEquals(images[0]['id'], self.fixtures[0]['id'])

View File

@ -498,16 +498,20 @@ class TestEndpoints(utils.BaseTestCase):
def setUp(self): def setUp(self):
self.service_catalog = [ self.service_catalog = [
{'endpoint_links': [], {
'endpoints': [ 'endpoint_links': [],
{'adminURL': 'http://localhost:8080/', 'endpoints': [
'region': 'RegionOne', {
'internalURL': 'http://internalURL/', 'adminURL': 'http://localhost:8080/',
'publicURL': 'http://publicURL/'}, 'region': 'RegionOne',
], 'internalURL': 'http://internalURL/',
'type': 'object-store', 'publicURL': 'http://publicURL/',
'name': 'Object Storage Service', },
}] ],
'type': 'object-store',
'name': 'Object Storage Service',
}
]
def test_get_endpoint_with_custom_server_type(self): def test_get_endpoint_with_custom_server_type(self):
endpoint = auth.get_endpoint(self.service_catalog, endpoint = auth.get_endpoint(self.service_catalog,

View File

@ -884,12 +884,13 @@ class TestRegistryClient(base.IsolatedUnitTest):
def test_add_image_basic(self): def test_add_image_basic(self):
"""Tests that we can add image metadata and returns the new id""" """Tests that we can add image metadata and returns the new id"""
fixture = {'name': 'fake public image', fixture = {
'is_public': True, 'name': 'fake public image',
'disk_format': 'vmdk', 'is_public': True,
'container_format': 'ovf', 'disk_format': 'vmdk',
'size': 19, 'container_format': 'ovf',
} 'size': 19,
}
new_image = self.client.add_image(fixture) new_image = self.client.add_image(fixture)
@ -925,14 +926,15 @@ class TestRegistryClient(base.IsolatedUnitTest):
def test_add_image_already_exists(self): def test_add_image_already_exists(self):
"""Tests proper exception is raised if image with ID already exists""" """Tests proper exception is raised if image with ID already exists"""
fixture = {'id': UUID2, fixture = {
'name': 'fake public image', 'id': UUID2,
'is_public': True, 'name': 'fake public image',
'disk_format': 'vmdk', 'is_public': True,
'container_format': 'ovf', 'disk_format': 'vmdk',
'size': 19, 'container_format': 'ovf',
'location': "file:///tmp/glance-tests/2", 'size': 19,
} 'location': "file:///tmp/glance-tests/2",
}
self.assertRaises(exception.Duplicate, self.assertRaises(exception.Duplicate,
self.client.add_image, self.client.add_image,
@ -940,14 +942,15 @@ class TestRegistryClient(base.IsolatedUnitTest):
def test_add_image_with_bad_status(self): def test_add_image_with_bad_status(self):
"""Tests proper exception is raised if a bad status is set""" """Tests proper exception is raised if a bad status is set"""
fixture = {'name': 'fake public image', fixture = {
'is_public': True, 'name': 'fake public image',
'disk_format': 'vmdk', 'is_public': True,
'container_format': 'ovf', 'disk_format': 'vmdk',
'status': 'bad status', 'container_format': 'ovf',
'size': 19, 'status': 'bad status',
'location': "file:///tmp/glance-tests/2", 'size': 19,
} 'location': "file:///tmp/glance-tests/2",
}
self.assertRaises(exception.Invalid, self.assertRaises(exception.Invalid,
self.client.add_image, self.client.add_image,
@ -968,12 +971,13 @@ class TestRegistryClient(base.IsolatedUnitTest):
def test_update_image_not_existing(self): def test_update_image_not_existing(self):
"""Tests non existing image update doesn't work""" """Tests non existing image update doesn't work"""
fixture = {'name': 'fake public image', fixture = {
'is_public': True, 'name': 'fake public image',
'disk_format': 'vmdk', 'is_public': True,
'container_format': 'ovf', 'disk_format': 'vmdk',
'status': 'bad status', 'container_format': 'ovf',
} 'status': 'bad status',
}
self.assertRaises(exception.NotFound, self.assertRaises(exception.NotFound,
self.client.update_image, self.client.update_image,

View File

@ -137,8 +137,7 @@ class TestMigrations(utils.BaseTestCase):
"|| tablename || ' cascade;' " "|| tablename || ' cascade;' "
"from pg_tables where schemaname = 'public';\" | " "from pg_tables where schemaname = 'public';\" | "
"psql -d %(database)s | grep '^\s*drop' | " "psql -d %(database)s | grep '^\s*drop' | "
"psql -d %(database)s" "psql -d %(database)s") % locals()
) % locals()
exitcode, out, err = utils.execute(cmd) exitcode, out, err = utils.execute(cmd)
self.assertEqual(0, exitcode) self.assertEqual(0, exitcode)

View File

@ -61,9 +61,10 @@ class TestImagesController(base.StoreClearingUnitTest):
self.assertEqual(4, output['meta']['size']) self.assertEqual(4, output['meta']['size'])
self.assertEqual('YYYY', output['data']) self.assertEqual('YYYY', output['data'])
output_log = self.notifier.get_log() output_log = self.notifier.get_log()
expected_log = {'notification_type': "INFO", expected_log = {
'event_type': "image.upload", 'notification_type': "INFO",
'payload': output['meta'], 'event_type': "image.upload",
'payload': output['meta'],
} }
self.assertEqual(output_log, expected_log) self.assertEqual(output_log, expected_log)

View File

@ -328,9 +328,10 @@ class TestImagesController(test_utils.BaseTestCase):
self.assertEqual([], output['tags']) self.assertEqual([], output['tags'])
self.assertEqual(False, output['is_public']) self.assertEqual(False, output['is_public'])
output_log = self.notifier.get_log() output_log = self.notifier.get_log()
expected_log = {'notification_type': "INFO", expected_log = {
'event_type': "image.update", 'notification_type': "INFO",
'payload': output, 'event_type': "image.update",
'payload': output,
} }
self.assertEqual(output_log, expected_log) self.assertEqual(output_log, expected_log)
@ -340,9 +341,10 @@ class TestImagesController(test_utils.BaseTestCase):
output = self.controller.create(request, image) output = self.controller.create(request, image)
self.assertEqual(True, output['is_public']) self.assertEqual(True, output['is_public'])
output_log = self.notifier.get_log() output_log = self.notifier.get_log()
expected_log = {'notification_type': "INFO", expected_log = {
'event_type': "image.update", 'notification_type': "INFO",
'payload': output, 'event_type': "image.update",
'payload': output,
} }
self.assertEqual(output_log, expected_log) self.assertEqual(output_log, expected_log)
@ -352,10 +354,11 @@ class TestImagesController(test_utils.BaseTestCase):
output = self.controller.create(request, image) output = self.controller.create(request, image)
self.assertEqual(['ping'], output['tags']) self.assertEqual(['ping'], output['tags'])
output_log = self.notifier.get_log() output_log = self.notifier.get_log()
expected_log = {'notification_type': "INFO", expected_log = {
'event_type': "image.update", 'notification_type': "INFO",
'payload': output, 'event_type': "image.update",
} 'payload': output,
}
self.assertEqual(output_log, expected_log) self.assertEqual(output_log, expected_log)
def test_update_no_changes(self): def test_update_no_changes(self):
@ -365,9 +368,10 @@ class TestImagesController(test_utils.BaseTestCase):
self.assertEqual(output['created_at'], output['updated_at']) self.assertEqual(output['created_at'], output['updated_at'])
self.assertTrue('tags' in output) self.assertTrue('tags' in output)
output_log = self.notifier.get_log() output_log = self.notifier.get_log()
expected_log = {'notification_type': "INFO", expected_log = {
'event_type': "image.update", 'notification_type': "INFO",
'payload': output, 'event_type': "image.update",
'payload': output,
} }
self.assertEqual(output_log, expected_log) self.assertEqual(output_log, expected_log)
@ -525,9 +529,10 @@ class TestImagesController(test_utils.BaseTestCase):
output = self.controller.update(request, UUID1, changes) output = self.controller.update(request, UUID1, changes)
self.assertEqual(['ping'], output['tags']) self.assertEqual(['ping'], output['tags'])
output_log = self.notifier.get_log() output_log = self.notifier.get_log()
expected_log = {'notification_type': "INFO", expected_log = {
'event_type': "image.update", 'notification_type': "INFO",
'payload': output, 'event_type': "image.update",
'payload': output,
} }
self.assertEqual(output_log, expected_log) self.assertEqual(output_log, expected_log)

View File

@ -328,10 +328,11 @@ def xattr_writes_supported(path):
def minimal_headers(name, public=True): def minimal_headers(name, public=True):
headers = {'Content-Type': 'application/octet-stream', headers = {
'X-Image-Meta-Name': name, 'Content-Type': 'application/octet-stream',
'X-Image-Meta-disk_format': 'raw', 'X-Image-Meta-Name': name,
'X-Image-Meta-container_format': 'ovf', 'X-Image-Meta-disk_format': 'raw',
'X-Image-Meta-container_format': 'ovf',
} }
if public: if public:
headers['X-Image-Meta-Is-Public'] = 'True' headers['X-Image-Meta-Is-Public'] = 'True'

View File

@ -18,7 +18,7 @@ downloadcache = ~/cache/pip
[testenv:pep8] [testenv:pep8]
deps = pep8==1.3.3 deps = pep8==1.3.3
commands = pep8 --ignore=E124,E125,E126,E127,E128,E711 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack . commands = pep8 --ignore=E125,E126,E127,E128,E711 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack .
[testenv:cover] [testenv:cover]
setenv = NOSE_WITH_COVERAGE=1 setenv = NOSE_WITH_COVERAGE=1