Enable F841 check
Enable F841 check: local variable 'name' assigned but never used. Make appropriate changes to files listed below. Change-Id: I02837d4abf421dc9d85f3b01587120fd68acfa12
This commit is contained in:
parent
31253812f5
commit
3fa66f63c4
@ -68,7 +68,7 @@ def safe_kill(req, image_id):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
_kill(req, image_id)
|
_kill(req, image_id)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
LOG.exception(_("Unable to kill image %(id)s: ") % {'id': image_id})
|
LOG.exception(_("Unable to kill image %(id)s: ") % {'id': image_id})
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ def define_image_properties_table(meta):
|
|||||||
(define_images_table,) = from_migration_import(
|
(define_images_table,) = from_migration_import(
|
||||||
'001_add_images_table', ['define_images_table'])
|
'001_add_images_table', ['define_images_table'])
|
||||||
|
|
||||||
images = define_images_table(meta)
|
images = define_images_table(meta) # noqa
|
||||||
|
|
||||||
# NOTE(dperaza) DB2: specify the UniqueConstraint option when creating the
|
# NOTE(dperaza) DB2: specify the UniqueConstraint option when creating the
|
||||||
# table will cause an index being created to specify the index
|
# table will cause an index being created to specify the index
|
||||||
|
@ -39,7 +39,7 @@ def get_image_properties_table(meta):
|
|||||||
(get_images_table,) = from_migration_import(
|
(get_images_table,) = from_migration_import(
|
||||||
'004_add_checksum', ['get_images_table'])
|
'004_add_checksum', ['get_images_table'])
|
||||||
|
|
||||||
images = get_images_table(meta)
|
images = get_images_table(meta) # noqa
|
||||||
|
|
||||||
image_properties = Table('image_properties',
|
image_properties = Table('image_properties',
|
||||||
meta,
|
meta,
|
||||||
|
@ -44,7 +44,7 @@ def get_image_properties_table(meta):
|
|||||||
|
|
||||||
|
|
||||||
def get_image_members_table(meta):
|
def get_image_members_table(meta):
|
||||||
images = get_images_table(meta)
|
images = get_images_table(meta) # noqa
|
||||||
|
|
||||||
image_members = Table('image_members',
|
image_members = Table('image_members',
|
||||||
meta,
|
meta,
|
||||||
|
@ -418,7 +418,7 @@ class Driver(base.Driver):
|
|||||||
path = self.get_image_filepath(image_id, 'queue')
|
path = self.get_image_filepath(image_id, 'queue')
|
||||||
|
|
||||||
# Touch the file to add it to the queue
|
# Touch the file to add it to the queue
|
||||||
with open(path, "w") as f:
|
with open(path, "w"):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -351,7 +351,7 @@ class Driver(base.Driver):
|
|||||||
LOG.debug(_("Queueing image '%s'."), image_id)
|
LOG.debug(_("Queueing image '%s'."), image_id)
|
||||||
|
|
||||||
# Touch the file to add it to the queue
|
# Touch the file to add it to the queue
|
||||||
with open(path, "w") as f:
|
with open(path, "w"):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -281,7 +281,7 @@ class ImageProxy(glance.domain.proxy.Image):
|
|||||||
data = utils.LimitingReader(data, remaining)
|
data = utils.LimitingReader(data, remaining)
|
||||||
try:
|
try:
|
||||||
self.image.set_data(data, size=size)
|
self.image.set_data(data, size=size)
|
||||||
except exception.ImageSizeLimitExceeded as ex:
|
except exception.ImageSizeLimitExceeded:
|
||||||
raise exception.StorageQuotaFull(image_size=size,
|
raise exception.StorageQuotaFull(image_size=size,
|
||||||
remaining=remaining)
|
remaining=remaining)
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ class Controller(object):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
members = self.db_api.image_member_find(req.context, member=id)
|
members = self.db_api.image_member_find(req.context, member=id)
|
||||||
except exception.NotFound as e:
|
except exception.NotFound:
|
||||||
msg = _("Member %(id)s not found")
|
msg = _("Member %(id)s not found")
|
||||||
LOG.info(msg % {'id': id})
|
LOG.info(msg % {'id': id})
|
||||||
msg = _("Membership could not be found.")
|
msg = _("Membership could not be found.")
|
||||||
|
@ -340,7 +340,7 @@ class ScrubDBQueue(ScrubQueue):
|
|||||||
try:
|
try:
|
||||||
image = self.registry.get_image(image_id)
|
image = self.registry.get_image(image_id)
|
||||||
return image['status'] == 'pending_delete'
|
return image['status'] == 'pending_delete'
|
||||||
except exception.NotFound as e:
|
except exception.NotFound:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,8 +209,7 @@ class Store(glance.store.base.Store):
|
|||||||
raise exception.BadStoreConfiguration(
|
raise exception.BadStoreConfiguration(
|
||||||
store_name='vmware_datastore', reason=reason)
|
store_name='vmware_datastore', reason=reason)
|
||||||
else:
|
else:
|
||||||
ds_validated = True
|
_datastore_info_valid = True
|
||||||
|
|
||||||
self.store_image_dir = CONF.vmware_store_image_dir
|
self.store_image_dir = CONF.vmware_store_image_dir
|
||||||
|
|
||||||
def _option_get(self, param):
|
def _option_get(self, param):
|
||||||
|
@ -1331,8 +1331,8 @@ class TaskTests(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def test_task_get_all_marker(self):
|
def test_task_get_all_marker(self):
|
||||||
for fixture in self.fixtures:
|
for fixture in self.fixtures:
|
||||||
task = self.db_api.task_create(self.context,
|
self.db_api.task_create(self.context,
|
||||||
build_task_fixture(**fixture))
|
build_task_fixture(**fixture))
|
||||||
tasks = self.db_api.task_get_all(self.context, sort_key='id')
|
tasks = self.db_api.task_get_all(self.context, sort_key='id')
|
||||||
task_ids = [t['id'] for t in tasks]
|
task_ids = [t['id'] for t in tasks]
|
||||||
tasks = self.db_api.task_get_all(self.context, sort_key='id',
|
tasks = self.db_api.task_get_all(self.context, sort_key='id',
|
||||||
|
@ -101,8 +101,7 @@ class TestSqlAlchemyDBDataIntegrity(base.TestDriver):
|
|||||||
|
|
||||||
self.stubs.Set(self.db_api, '_paginate_query',
|
self.stubs.Set(self.db_api, '_paginate_query',
|
||||||
fake_paginate_query)
|
fake_paginate_query)
|
||||||
images = self.db_api.image_get_all(self.context,
|
self.db_api.image_get_all(self.context, sort_key='created_at')
|
||||||
sort_key='created_at')
|
|
||||||
|
|
||||||
def test_paginate_non_redundant_sort_keys(self):
|
def test_paginate_non_redundant_sort_keys(self):
|
||||||
original_method = self.db_api._paginate_query
|
original_method = self.db_api._paginate_query
|
||||||
@ -115,8 +114,7 @@ class TestSqlAlchemyDBDataIntegrity(base.TestDriver):
|
|||||||
|
|
||||||
self.stubs.Set(self.db_api, '_paginate_query',
|
self.stubs.Set(self.db_api, '_paginate_query',
|
||||||
fake_paginate_query)
|
fake_paginate_query)
|
||||||
images = self.db_api.image_get_all(self.context,
|
self.db_api.image_get_all(self.context, sort_key='name')
|
||||||
sort_key='name')
|
|
||||||
|
|
||||||
|
|
||||||
class TestSqlAlchemyTask(base.TaskTests):
|
class TestSqlAlchemyTask(base.TaskTests):
|
||||||
|
@ -42,7 +42,7 @@ class TestSheepdogStore(store_tests.BaseTestCase, testtools.TestCase):
|
|||||||
sheepdog.DEFAULT_CHUNKSIZE)
|
sheepdog.DEFAULT_CHUNKSIZE)
|
||||||
try:
|
try:
|
||||||
image.create(512)
|
image.create(512)
|
||||||
except BackendException as e:
|
except BackendException:
|
||||||
msg = "Sheepdog cluster isn't set up"
|
msg = "Sheepdog cluster isn't set up"
|
||||||
self.skipTest(msg)
|
self.skipTest(msg)
|
||||||
image.delete()
|
image.delete()
|
||||||
|
@ -436,7 +436,6 @@ class TestSwiftStore(store_tests.BaseTestCase, testtools.TestCase):
|
|||||||
|
|
||||||
def test_multitenant(self):
|
def test_multitenant(self):
|
||||||
"""Ensure an image is properly configured when using multitenancy."""
|
"""Ensure an image is properly configured when using multitenancy."""
|
||||||
fake_swift_admin = 'd2f68325-8e2c-4fb1-8c8b-89de2f3d9c4a'
|
|
||||||
self.config(
|
self.config(
|
||||||
swift_store_multi_tenant=True,
|
swift_store_multi_tenant=True,
|
||||||
)
|
)
|
||||||
|
@ -102,7 +102,6 @@ class TestMiscellaneous(functional.FunctionalTest):
|
|||||||
self.start_servers()
|
self.start_servers()
|
||||||
|
|
||||||
api_port = self.api_port
|
api_port = self.api_port
|
||||||
registry_port = self.registry_port
|
|
||||||
|
|
||||||
cmd = "curl -g http://127.0.0.1:%d/v1/images" % api_port
|
cmd = "curl -g http://127.0.0.1:%d/v1/images" % api_port
|
||||||
|
|
||||||
|
@ -1213,8 +1213,8 @@ class TestImages(functional.FunctionalTest):
|
|||||||
self.assertEqual('2', image['x_all_permitted_joe_soap'])
|
self.assertEqual('2', image['x_all_permitted_joe_soap'])
|
||||||
path = self._url('/v2/images/%s' % image_id)
|
path = self._url('/v2/images/%s' % image_id)
|
||||||
media_type = 'application/openstack-images-v2.1-json-patch'
|
media_type = 'application/openstack-images-v2.1-json-patch'
|
||||||
header = self._headers({'content-type': media_type,
|
headers = self._headers({'content-type': media_type,
|
||||||
'X-Roles': 'joe_soap'})
|
'X-Roles': 'joe_soap'})
|
||||||
data = jsonutils.dumps([
|
data = jsonutils.dumps([
|
||||||
{'op': 'replace',
|
{'op': 'replace',
|
||||||
'path': '/x_all_permitted_joe_soap', 'value': '3'}
|
'path': '/x_all_permitted_joe_soap', 'value': '3'}
|
||||||
|
@ -355,7 +355,7 @@ class GetSocketTestCase(test_utils.BaseTestCase):
|
|||||||
self.useFixture(fixtures.MonkeyPatch(
|
self.useFixture(fixtures.MonkeyPatch(
|
||||||
'glance.common.wsgi.eventlet.listen',
|
'glance.common.wsgi.eventlet.listen',
|
||||||
lambda *x, **y: None))
|
lambda *x, **y: None))
|
||||||
sock = wsgi.get_socket(1234)
|
wsgi.get_socket(1234)
|
||||||
self.assertTrue(mock.call().setsockopt(
|
self.assertTrue(mock.call().setsockopt(
|
||||||
socket.SOL_SOCKET,
|
socket.SOL_SOCKET,
|
||||||
socket.SO_REUSEADDR,
|
socket.SO_REUSEADDR,
|
||||||
|
@ -302,7 +302,7 @@ class ImageCacheTestCase(object):
|
|||||||
image_id = '1'
|
image_id = '1'
|
||||||
self.assertFalse(self.cache.is_cached(image_id))
|
self.assertFalse(self.cache.is_cached(image_id))
|
||||||
try:
|
try:
|
||||||
with self.cache.driver.open_for_write(image_id) as cache_file:
|
with self.cache.driver.open_for_write(image_id):
|
||||||
raise IOError
|
raise IOError
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.assertIsInstance(e, IOError)
|
self.assertIsInstance(e, IOError)
|
||||||
|
@ -1070,7 +1070,6 @@ class TestMigrations(test_utils.BaseTestCase):
|
|||||||
images.insert().values(temp).execute()
|
images.insert().values(temp).execute()
|
||||||
|
|
||||||
locations_table = get_table(engine, 'image_locations')
|
locations_table = get_table(engine, 'image_locations')
|
||||||
data = image_id
|
|
||||||
locations = [
|
locations = [
|
||||||
('file://ab', '{"a": "yo yo"}'),
|
('file://ab', '{"a": "yo yo"}'),
|
||||||
('file://ab', '{}'),
|
('file://ab', '{}'),
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@ -52,7 +51,6 @@ class TestScrubber(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
uri = 'file://some/path/%s' % (fname)
|
uri = 'file://some/path/%s' % (fname)
|
||||||
id = 'helloworldid'
|
id = 'helloworldid'
|
||||||
now = time.time()
|
|
||||||
scrub = scrubber.Scrubber(glance.store)
|
scrub = scrubber.Scrubber(glance.store)
|
||||||
scrub.registry = self.mox.CreateMockAnything()
|
scrub.registry = self.mox.CreateMockAnything()
|
||||||
scrub.registry.get_image(id).AndReturn({'status': 'pending_delete'})
|
scrub.registry.get_image(id).AndReturn({'status': 'pending_delete'})
|
||||||
|
@ -462,7 +462,7 @@ class TestStoreLocation(base.StoreClearingUnitTest):
|
|||||||
|
|
||||||
self.stubs.Set(glance.store, 'get_size_from_backend',
|
self.stubs.Set(glance.store, 'get_size_from_backend',
|
||||||
fake_get_size_from_backend)
|
fake_get_size_from_backend)
|
||||||
with mock.patch('glance.store._check_image_location') as _:
|
with mock.patch('glance.store._check_image_location'):
|
||||||
loc1 = {'url': 'file:///fake1.img.tar.gz', 'metadata': {}}
|
loc1 = {'url': 'file:///fake1.img.tar.gz', 'metadata': {}}
|
||||||
loc2 = {'url': 'file:///fake2.img.tar.gz', 'metadata': {}}
|
loc2 = {'url': 'file:///fake2.img.tar.gz', 'metadata': {}}
|
||||||
|
|
||||||
|
@ -586,7 +586,6 @@ class SwiftTests(object):
|
|||||||
def test_add_saves_and_reraises_and_not_uses_wildcard_raise(self):
|
def test_add_saves_and_reraises_and_not_uses_wildcard_raise(self):
|
||||||
image_id = str(uuid.uuid4())
|
image_id = str(uuid.uuid4())
|
||||||
swift_size = self.store.large_object_size = 1024
|
swift_size = self.store.large_object_size = 1024
|
||||||
loc = 'swift+https://%s:key@localhost:8080/glance/%s'
|
|
||||||
swift_contents = "*" * swift_size
|
swift_contents = "*" * swift_size
|
||||||
connection = mock.Mock()
|
connection = mock.Mock()
|
||||||
|
|
||||||
@ -966,7 +965,7 @@ class TestCreatingLocations(base.IsolatedUnitTest):
|
|||||||
context = glance.context.RequestContext(
|
context = glance.context.RequestContext(
|
||||||
user='user', tenant='tenant', auth_tok='123',
|
user='user', tenant='tenant', auth_tok='123',
|
||||||
service_catalog={})
|
service_catalog={})
|
||||||
store = glance.store.swift.MultiTenantStore(context)
|
glance.store.swift.MultiTenantStore(context)
|
||||||
self.assertEqual(fake_get_endpoint.endpoint_region, 'WestCarolina')
|
self.assertEqual(fake_get_endpoint.endpoint_region, 'WestCarolina')
|
||||||
|
|
||||||
def test_multi_tenant_location_custom_service_type(self):
|
def test_multi_tenant_location_custom_service_type(self):
|
||||||
@ -976,7 +975,7 @@ class TestCreatingLocations(base.IsolatedUnitTest):
|
|||||||
context = glance.context.RequestContext(
|
context = glance.context.RequestContext(
|
||||||
user='user', tenant='tenant', auth_tok='123',
|
user='user', tenant='tenant', auth_tok='123',
|
||||||
service_catalog={})
|
service_catalog={})
|
||||||
store = glance.store.swift.MultiTenantStore(context)
|
glance.store.swift.MultiTenantStore(context)
|
||||||
self.assertEqual(fake_get_endpoint.service_type, 'toy-store')
|
self.assertEqual(fake_get_endpoint.service_type, 'toy-store')
|
||||||
|
|
||||||
def test_multi_tenant_location_custom_endpoint_type(self):
|
def test_multi_tenant_location_custom_endpoint_type(self):
|
||||||
@ -986,7 +985,7 @@ class TestCreatingLocations(base.IsolatedUnitTest):
|
|||||||
context = glance.context.RequestContext(
|
context = glance.context.RequestContext(
|
||||||
user='user', tenant='tenant', auth_tok='123',
|
user='user', tenant='tenant', auth_tok='123',
|
||||||
service_catalog={})
|
service_catalog={})
|
||||||
store = glance.store.swift.MultiTenantStore(context)
|
glance.store.swift.MultiTenantStore(context)
|
||||||
self.assertEqual(fake_get_endpoint.endpoint_type, 'InternalURL')
|
self.assertEqual(fake_get_endpoint.endpoint_type, 'InternalURL')
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,19 +108,18 @@ class TestStore(base.StoreClearingUnitTest):
|
|||||||
class FakeCookieJar:
|
class FakeCookieJar:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with mock.patch.object(Store, 'configure') as store:
|
self.store.scheme = VMWARE_DATASTORE_CONF['default_store']
|
||||||
self.store.scheme = VMWARE_DATASTORE_CONF['default_store']
|
self.store.server_host = (
|
||||||
self.store.server_host = (
|
VMWARE_DATASTORE_CONF['vmware_server_host'])
|
||||||
VMWARE_DATASTORE_CONF['vmware_server_host'])
|
self.store.datacenter_path = (
|
||||||
self.store.datacenter_path = (
|
VMWARE_DATASTORE_CONF['vmware_datacenter_path'])
|
||||||
VMWARE_DATASTORE_CONF['vmware_datacenter_path'])
|
self.store.datastore_name = (
|
||||||
self.store.datastore_name = (
|
VMWARE_DATASTORE_CONF['vmware_datastore_name'])
|
||||||
VMWARE_DATASTORE_CONF['vmware_datastore_name'])
|
self.store.api_insecure = (
|
||||||
self.store.api_insecure = (
|
VMWARE_DATASTORE_CONF['vmware_api_insecure'])
|
||||||
VMWARE_DATASTORE_CONF['vmware_api_insecure'])
|
self.store._session = FakeSession()
|
||||||
self.store._session = FakeSession()
|
self.store._session.invoke_api = mock.Mock()
|
||||||
self.store._session.invoke_api = mock.Mock()
|
self.store._session.wait_for_task = mock.Mock()
|
||||||
self.store._session.wait_for_task = mock.Mock()
|
|
||||||
|
|
||||||
self.store.store_image_dir = (
|
self.store.store_image_dir = (
|
||||||
VMWARE_DATASTORE_CONF['vmware_store_image_dir'])
|
VMWARE_DATASTORE_CONF['vmware_store_image_dir'])
|
||||||
|
@ -2531,7 +2531,6 @@ class TestGlanceAPI(base.IsolatedUnitTest):
|
|||||||
req.method = 'HEAD'
|
req.method = 'HEAD'
|
||||||
res = req.get_response(self.api)
|
res = req.get_response(self.api)
|
||||||
self.assertEqual(res.status_int, 200)
|
self.assertEqual(res.status_int, 200)
|
||||||
orig_value = res.headers[k]
|
|
||||||
|
|
||||||
req = webob.Request.blank('/images/%s' % UUID2)
|
req = webob.Request.blank('/images/%s' % UUID2)
|
||||||
req.headers[k] = v
|
req.headers[k] = v
|
||||||
@ -3348,8 +3347,7 @@ class TestAPIProtectedProps(base.IsolatedUnitTest):
|
|||||||
permitted role 'member' can read that protected property via
|
permitted role 'member' can read that protected property via
|
||||||
/images/detail
|
/images/detail
|
||||||
"""
|
"""
|
||||||
image_id = self._create_admin_image(
|
self._create_admin_image({'x-image-meta-property-x_owner_foo': 'bar'})
|
||||||
{'x-image-meta-property-x_owner_foo': 'bar'})
|
|
||||||
another_request = unit_test_utils.get_fake_request(
|
another_request = unit_test_utils.get_fake_request(
|
||||||
method='GET', path='/images/detail')
|
method='GET', path='/images/detail')
|
||||||
headers = {'x-auth-token': 'user:tenant:member'}
|
headers = {'x-auth-token': 'user:tenant:member'}
|
||||||
@ -3367,8 +3365,7 @@ class TestAPIProtectedProps(base.IsolatedUnitTest):
|
|||||||
/images/detail
|
/images/detail
|
||||||
"""
|
"""
|
||||||
self.set_property_protections(use_policies=True)
|
self.set_property_protections(use_policies=True)
|
||||||
image_id = self._create_admin_image(
|
self._create_admin_image({'x-image-meta-property-x_owner_foo': 'bar'})
|
||||||
{'x-image-meta-property-x_owner_foo': 'bar'})
|
|
||||||
another_request = unit_test_utils.get_fake_request(
|
another_request = unit_test_utils.get_fake_request(
|
||||||
method='GET', path='/images/detail')
|
method='GET', path='/images/detail')
|
||||||
headers = {'x-auth-token': 'user:tenant:member'}
|
headers = {'x-auth-token': 'user:tenant:member'}
|
||||||
@ -3385,8 +3382,7 @@ class TestAPIProtectedProps(base.IsolatedUnitTest):
|
|||||||
permitted role 'fake_role' can *not* read that protected property via
|
permitted role 'fake_role' can *not* read that protected property via
|
||||||
/images/detail
|
/images/detail
|
||||||
"""
|
"""
|
||||||
image_id = self._create_admin_image(
|
self._create_admin_image({'x-image-meta-property-x_owner_foo': 'bar'})
|
||||||
{'x-image-meta-property-x_owner_foo': 'bar'})
|
|
||||||
another_request = unit_test_utils.get_fake_request(
|
another_request = unit_test_utils.get_fake_request(
|
||||||
method='GET', path='/images/detail')
|
method='GET', path='/images/detail')
|
||||||
headers = {'x-auth-token': 'user:tenant:fake_role'}
|
headers = {'x-auth-token': 'user:tenant:fake_role'}
|
||||||
@ -3405,8 +3401,7 @@ class TestAPIProtectedProps(base.IsolatedUnitTest):
|
|||||||
/images/detail
|
/images/detail
|
||||||
"""
|
"""
|
||||||
self.set_property_protections(use_policies=True)
|
self.set_property_protections(use_policies=True)
|
||||||
image_id = self._create_admin_image(
|
self._create_admin_image({'x-image-meta-property-x_owner_foo': 'bar'})
|
||||||
{'x-image-meta-property-x_owner_foo': 'bar'})
|
|
||||||
another_request = unit_test_utils.get_fake_request(
|
another_request = unit_test_utils.get_fake_request(
|
||||||
method='GET', path='/images/detail')
|
method='GET', path='/images/detail')
|
||||||
headers = {'x-auth-token': 'user:tenant:fake_role'}
|
headers = {'x-auth-token': 'user:tenant:fake_role'}
|
||||||
|
@ -518,7 +518,6 @@ class TestRegistryV1Client(base.IsolatedUnitTest, test_utils.RegistryAPIMixIn):
|
|||||||
iso2 = timeutils.isotime(dt2)
|
iso2 = timeutils.isotime(dt2)
|
||||||
|
|
||||||
dt3 = timeutils.utcnow() + datetime.timedelta(2)
|
dt3 = timeutils.utcnow() + datetime.timedelta(2)
|
||||||
iso3 = timeutils.isotime(dt3)
|
|
||||||
|
|
||||||
dt4 = timeutils.utcnow() + datetime.timedelta(3)
|
dt4 = timeutils.utcnow() + datetime.timedelta(3)
|
||||||
iso4 = timeutils.isotime(dt4)
|
iso4 = timeutils.isotime(dt4)
|
||||||
|
@ -196,9 +196,7 @@ class TestUploadUtils(base.StoreClearingUnitTest):
|
|||||||
def _test_upload_data_to_store_exception(self, exc_class, expected_class):
|
def _test_upload_data_to_store_exception(self, exc_class, expected_class):
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
|
|
||||||
location = "file://foo/bar"
|
|
||||||
size = 10
|
size = 10
|
||||||
checksum = "checksum"
|
|
||||||
|
|
||||||
image_meta = {'id': unit_test_utils.UUID1,
|
image_meta = {'id': unit_test_utils.UUID1,
|
||||||
'size': size}
|
'size': size}
|
||||||
@ -227,9 +225,7 @@ class TestUploadUtils(base.StoreClearingUnitTest):
|
|||||||
image_killed=True):
|
image_killed=True):
|
||||||
req = unit_test_utils.get_fake_request()
|
req = unit_test_utils.get_fake_request()
|
||||||
|
|
||||||
location = "file://foo/bar"
|
|
||||||
size = 10
|
size = 10
|
||||||
checksum = "checksum"
|
|
||||||
|
|
||||||
image_meta = {'id': unit_test_utils.UUID1,
|
image_meta = {'id': unit_test_utils.UUID1,
|
||||||
'size': size}
|
'size': size}
|
||||||
|
@ -305,15 +305,11 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
def test_update_done_by_owner(self):
|
def test_update_done_by_owner(self):
|
||||||
request = unit_test_utils.get_fake_request(tenant=TENANT1)
|
request = unit_test_utils.get_fake_request(tenant=TENANT1)
|
||||||
image_id = UUID2
|
|
||||||
member_id = TENANT4
|
|
||||||
self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,
|
self.assertRaises(webob.exc.HTTPForbidden, self.controller.update,
|
||||||
request, UUID2, TENANT4, status='accepted')
|
request, UUID2, TENANT4, status='accepted')
|
||||||
|
|
||||||
def test_update_invalid_status(self):
|
def test_update_invalid_status(self):
|
||||||
request = unit_test_utils.get_fake_request(tenant=TENANT4)
|
request = unit_test_utils.get_fake_request(tenant=TENANT4)
|
||||||
image_id = UUID2
|
|
||||||
member_id = TENANT4
|
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.update,
|
||||||
request, UUID2, TENANT4, status='accept')
|
request, UUID2, TENANT4, status='accept')
|
||||||
|
|
||||||
@ -513,14 +509,12 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||||||
def test_create(self):
|
def test_create(self):
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
request.body = jsonutils.dumps({'member': TENANT1})
|
request.body = jsonutils.dumps({'member': TENANT1})
|
||||||
image_id = UUID1
|
|
||||||
output = self.deserializer.create(request)
|
output = self.deserializer.create(request)
|
||||||
expected = {'member_id': TENANT1}
|
expected = {'member_id': TENANT1}
|
||||||
self.assertEqual(expected, output)
|
self.assertEqual(expected, output)
|
||||||
|
|
||||||
def test_create_invalid(self):
|
def test_create_invalid(self):
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
image_id = UUID1
|
|
||||||
request.body = jsonutils.dumps({'mem': TENANT1})
|
request.body = jsonutils.dumps({'mem': TENANT1})
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.create,
|
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.create,
|
||||||
request)
|
request)
|
||||||
@ -539,16 +533,12 @@ class TestImagesDeserializer(test_utils.BaseTestCase):
|
|||||||
def test_update(self):
|
def test_update(self):
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
request.body = jsonutils.dumps({'status': 'accepted'})
|
request.body = jsonutils.dumps({'status': 'accepted'})
|
||||||
image_id = UUID1
|
|
||||||
member_id = TENANT1
|
|
||||||
output = self.deserializer.update(request)
|
output = self.deserializer.update(request)
|
||||||
expected = {'status': 'accepted'}
|
expected = {'status': 'accepted'}
|
||||||
self.assertEqual(expected, output)
|
self.assertEqual(expected, output)
|
||||||
|
|
||||||
def test_update_invalid(self):
|
def test_update_invalid(self):
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
image_id = UUID1
|
|
||||||
member_id = TENANT1
|
|
||||||
request.body = jsonutils.dumps({'mem': TENANT1})
|
request.body = jsonutils.dumps({'mem': TENANT1})
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.update,
|
self.assertRaises(webob.exc.HTTPBadRequest, self.deserializer.update,
|
||||||
request)
|
request)
|
||||||
|
@ -704,7 +704,6 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
def test_update_add_too_many_properties(self):
|
def test_update_add_too_many_properties(self):
|
||||||
self.config(image_property_quota=1)
|
self.config(image_property_quota=1)
|
||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
output = self.controller.show(request, UUID1)
|
|
||||||
|
|
||||||
changes = [
|
changes = [
|
||||||
{'op': 'add', 'path': ['foo'], 'value': 'baz'},
|
{'op': 'add', 'path': ['foo'], 'value': 'baz'},
|
||||||
@ -1021,7 +1020,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
{'op': 'replace', 'path': ['x_owner_foo'], 'value': 'baz'},
|
{'op': 'replace', 'path': ['x_owner_foo'], 'value': 'baz'},
|
||||||
]
|
]
|
||||||
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
||||||
request, UUID1, changes)
|
another_request, created_image.image_id, changes)
|
||||||
|
|
||||||
def test_prop_protection_with_delete_and_permitted_role(self):
|
def test_prop_protection_with_delete_and_permitted_role(self):
|
||||||
enforcer = glance.api.policy.Enforcer()
|
enforcer = glance.api.policy.Enforcer()
|
||||||
@ -1063,7 +1062,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
{'op': 'remove', 'path': ['x_owner_foo']}
|
{'op': 'remove', 'path': ['x_owner_foo']}
|
||||||
]
|
]
|
||||||
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
||||||
request, UUID1, changes)
|
another_request, created_image.image_id, changes)
|
||||||
|
|
||||||
def test_create_non_protected_prop(self):
|
def test_create_non_protected_prop(self):
|
||||||
"""
|
"""
|
||||||
@ -1081,7 +1080,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
'1')
|
'1')
|
||||||
another_request = unit_test_utils.get_fake_request(roles=['joe_soap'])
|
another_request = unit_test_utils.get_fake_request(roles=['joe_soap'])
|
||||||
extra_props = {'x_all_permitted_2': '2'}
|
extra_props = {'x_all_permitted_2': '2'}
|
||||||
created_image = self.controller.create(request, image=image,
|
created_image = self.controller.create(another_request, image=image,
|
||||||
extra_properties=extra_props,
|
extra_properties=extra_props,
|
||||||
tags=[])
|
tags=[])
|
||||||
self.assertEqual(created_image.extra_properties['x_all_permitted_2'],
|
self.assertEqual(created_image.extra_properties['x_all_permitted_2'],
|
||||||
@ -1195,7 +1194,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
{'op': 'replace', 'path': ['x_none_update'], 'value': 'baz'},
|
{'op': 'replace', 'path': ['x_none_update'], 'value': 'baz'},
|
||||||
]
|
]
|
||||||
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
||||||
request, UUID1, changes)
|
another_request, created_image.image_id, changes)
|
||||||
|
|
||||||
def test_delete_locked_down_protected_prop(self):
|
def test_delete_locked_down_protected_prop(self):
|
||||||
"""
|
"""
|
||||||
@ -1213,7 +1212,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
{'op': 'remove', 'path': ['x_none_delete']}
|
{'op': 'remove', 'path': ['x_none_delete']}
|
||||||
]
|
]
|
||||||
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
self.assertRaises(webob.exc.HTTPConflict, self.controller.update,
|
||||||
request, UUID1, changes)
|
another_request, created_image.image_id, changes)
|
||||||
|
|
||||||
def test_update_replace_locations(self):
|
def test_update_replace_locations(self):
|
||||||
self.stubs.Set(glance.store, 'get_size_from_backend',
|
self.stubs.Set(glance.store, 'get_size_from_backend',
|
||||||
@ -1643,7 +1642,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
request = unit_test_utils.get_fake_request()
|
request = unit_test_utils.get_fake_request()
|
||||||
self.assertTrue(filter(lambda k: UUID1 in k, self.store.data))
|
self.assertTrue(filter(lambda k: UUID1 in k, self.store.data))
|
||||||
try:
|
try:
|
||||||
image = self.controller.delete(request, UUID1)
|
self.controller.delete(request, UUID1)
|
||||||
output_logs = self.notifier.get_logs()
|
output_logs = self.notifier.get_logs()
|
||||||
self.assertEqual(len(output_logs), 1)
|
self.assertEqual(len(output_logs), 1)
|
||||||
output_log = output_logs[0]
|
output_log = output_logs[0]
|
||||||
@ -1736,7 +1735,6 @@ class TestImagesController(base.IsolatedUnitTest):
|
|||||||
self.controller.index, request, marker=fake_uuid)
|
self.controller.index, request, marker=fake_uuid)
|
||||||
|
|
||||||
def test_invalid_locations_op_pos(self):
|
def test_invalid_locations_op_pos(self):
|
||||||
request = unit_test_utils.get_fake_request()
|
|
||||||
pos = self.controller._get_locations_op_pos(None, 2, True)
|
pos = self.controller._get_locations_op_pos(None, 2, True)
|
||||||
self.assertEqual(pos, None)
|
self.assertEqual(pos, None)
|
||||||
pos = self.controller._get_locations_op_pos('1', None, True)
|
pos = self.controller._get_locations_op_pos('1', None, True)
|
||||||
|
3
tox.ini
3
tox.ini
@ -31,10 +31,9 @@ commands = {posargs}
|
|||||||
# E711 comparison to None should be 'if cond is not None:'
|
# E711 comparison to None should be 'if cond is not None:'
|
||||||
# E712 comparison to True should be 'if cond is True:' or 'if cond:'
|
# E712 comparison to True should be 'if cond is True:' or 'if cond:'
|
||||||
# F821 undefined name 'name'
|
# F821 undefined name 'name'
|
||||||
# F841 local variable 'name' assigned but never used
|
|
||||||
# H301 one import per line
|
# H301 one import per line
|
||||||
# H402 one line docstring needs punctuation.
|
# H402 one line docstring needs punctuation.
|
||||||
# H404 multi line docstring should start with a summary
|
# H404 multi line docstring should start with a summary
|
||||||
ignore = E711,E712,F821,F841,H301,H402,H404
|
ignore = E711,E712,F821,H301,H402,H404
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build
|
exclude = .venv,.git,.tox,dist,doc,etc,*glance/locale*,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
Loading…
Reference in New Issue
Block a user