Merge "Clean imports in code"

This commit is contained in:
Jenkins 2016-11-18 08:33:17 +00:00 committed by Gerrit Code Review
commit 2689a350c3
5 changed files with 27 additions and 29 deletions

View File

@ -14,7 +14,7 @@
import logging
from collections import OrderedDict
import collections
from oslo_config import cfg
from six.moves import configparser
@ -105,7 +105,7 @@ _config_defaults = {'user_domain_id': 'default',
# NOTE(bourke): The default dict_type is collections.OrderedDict in py27, but
# we must set manually for compatibility with py26
CONFIG = configparser.SafeConfigParser(defaults=_config_defaults,
dict_type=OrderedDict)
dict_type=collections.OrderedDict)
LOG = logging.getLogger(__name__)

View File

@ -30,8 +30,7 @@ from six.moves import builtins
# NOTE(jokke): simplified transition to py3, behaves like py2 xrange
from six.moves import range
from glance_store._drivers.filesystem import ChunkedFile
from glance_store._drivers.filesystem import Store
from glance_store._drivers import filesystem
from glance_store import exceptions
from glance_store import location
from glance_store.tests import base
@ -44,9 +43,9 @@ class TestStore(base.StoreBaseTest,
def setUp(self):
"""Establish a clean test environment."""
super(TestStore, self).setUp()
self.orig_chunksize = Store.READ_CHUNKSIZE
Store.READ_CHUNKSIZE = 10
self.store = Store(self.conf)
self.orig_chunksize = filesystem.Store.READ_CHUNKSIZE
filesystem.Store.READ_CHUNKSIZE = 10
self.store = filesystem.Store(self.conf)
self.config(filesystem_store_datadir=self.test_dir,
stores=['glance.store.filesystem.Store'],
group="glance_store")
@ -56,7 +55,7 @@ class TestStore(base.StoreBaseTest,
def tearDown(self):
"""Clear the test environment."""
super(TestStore, self).tearDown()
ChunkedFile.CHUNKSIZE = self.orig_chunksize
filesystem.ChunkedFile.CHUNKSIZE = self.orig_chunksize
def _create_metadata_json_file(self, metadata):
expected_image_id = str(uuid.uuid4())
@ -153,7 +152,7 @@ class TestStore(base.StoreBaseTest,
def test_add(self):
"""Test that we can add an image via the filesystem backend."""
ChunkedFile.CHUNKSIZE = units.Ki
filesystem.ChunkedFile.CHUNKSIZE = units.Ki
expected_image_id = str(uuid.uuid4())
expected_file_size = 5 * units.Ki # 5K
expected_file_contents = b"*" * expected_file_size
@ -236,7 +235,7 @@ class TestStore(base.StoreBaseTest,
Tests that adding an image with an existing identifier
raises an appropriate exception
"""
ChunkedFile.CHUNKSIZE = units.Ki
filesystem.ChunkedFile.CHUNKSIZE = units.Ki
image_id = str(uuid.uuid4())
file_size = 5 * units.Ki # 5K
file_contents = b"*" * file_size
@ -251,7 +250,7 @@ class TestStore(base.StoreBaseTest,
image_id, image_file, 0)
def _do_test_add_write_failure(self, errno, exception):
ChunkedFile.CHUNKSIZE = units.Ki
filesystem.ChunkedFile.CHUNKSIZE = units.Ki
image_id = str(uuid.uuid4())
file_size = 5 * units.Ki # 5K
file_contents = b"*" * file_size
@ -302,7 +301,7 @@ class TestStore(base.StoreBaseTest,
Tests the partial image file is cleaned up after a read
failure.
"""
ChunkedFile.CHUNKSIZE = units.Ki
filesystem.ChunkedFile.CHUNKSIZE = units.Ki
image_id = str(uuid.uuid4())
file_size = 5 * units.Ki # 5K
file_contents = b"*" * file_size
@ -519,7 +518,7 @@ class TestStore(base.StoreBaseTest,
self.fail("configure() raised BadStoreConfiguration unexpectedly!")
# Test that we can add an image via the filesystem backend
ChunkedFile.CHUNKSIZE = 1024
filesystem.ChunkedFile.CHUNKSIZE = 1024
expected_image_id = str(uuid.uuid4())
expected_file_size = 5 * units.Ki # 5K
expected_file_contents = b"*" * expected_file_size
@ -565,7 +564,7 @@ class TestStore(base.StoreBaseTest,
self.store.configure()
# Test that we can add an image via the filesystem backend
ChunkedFile.CHUNKSIZE = units.Ki
filesystem.ChunkedFile.CHUNKSIZE = units.Ki
expected_image_id = str(uuid.uuid4())
expected_file_size = 5 * units.Ki # 5K
expected_file_contents = b"*" * expected_file_size
@ -618,7 +617,7 @@ class TestStore(base.StoreBaseTest,
with mock.patch.object(self.store, '_get_capacity_info') as capacity:
capacity.return_value = 0
ChunkedFile.CHUNKSIZE = units.Ki
filesystem.ChunkedFile.CHUNKSIZE = units.Ki
expected_image_id = str(uuid.uuid4())
expected_file_size = 5 * units.Ki # 5K
expected_file_contents = b"*" * expected_file_size
@ -671,7 +670,7 @@ class TestStore(base.StoreBaseTest,
self.store.configure_add()
Store.WRITE_CHUNKSIZE = units.Ki
filesystem.Store.WRITE_CHUNKSIZE = units.Ki
expected_image_id = str(uuid.uuid4())
expected_file_size = 5 * units.Ki # 5K
expected_file_contents = b"*" * expected_file_size
@ -712,7 +711,7 @@ class TestStore(base.StoreBaseTest,
self.store.configure_add()
Store.WRITE_CHUNKSIZE = units.Ki
filesystem.Store.WRITE_CHUNKSIZE = units.Ki
expected_image_id = str(uuid.uuid4())
expected_file_size = 5 * units.Ki # 5K
expected_file_contents = b"*" * expected_file_size

View File

@ -19,7 +19,7 @@ import six
from glance_store._drivers import rbd as rbd_store
from glance_store import exceptions
from glance_store.location import Location
from glance_store import location as g_location
from glance_store.tests import base
from glance_store.tests.unit import test_store_capabilities
@ -248,10 +248,10 @@ class TestStore(base.StoreBaseTest,
with mock.patch.object(MockRBD.RBD, 'remove') as remove_image:
remove_image.side_effect = _fake_remove
self.store.delete(Location('test_rbd_store',
rbd_store.StoreLocation,
self.conf,
uri=self.location.get_uri()))
self.store.delete(g_location.Location('test_rbd_store',
rbd_store.StoreLocation,
self.conf,
uri=self.location.get_uri()))
self.called_commands_expected = ['remove']
def test_delete_image(self):
@ -326,8 +326,8 @@ class TestStore(base.StoreBaseTest,
self.called_commands_expected = ['remove']
def test_get_partial_image(self):
loc = Location('test_rbd_store', rbd_store.StoreLocation, self.conf,
store_specs=self.store_specs)
loc = g_location.Location('test_rbd_store', rbd_store.StoreLocation,
self.conf, store_specs=self.store_specs)
self.assertRaises(exceptions.StoreRandomGetNotSupported,
self.store.get, loc, chunk_size=1)

View File

@ -37,7 +37,6 @@ import swiftclient
from glance_store._drivers.swift import store as swift
from glance_store._drivers.swift import utils as sutils
from glance_store import backend
from glance_store import BackendException
from glance_store import capabilities
from glance_store import exceptions
from glance_store import location
@ -482,7 +481,7 @@ class SwiftTests(object):
exception_caught = False
try:
self.store.add(str(uuid.uuid4()), image_swift, 0)
except BackendException as e:
except exceptions.BackendException as e:
exception_caught = True
self.assertIn("container noexist does not exist in Swift",
encodeutils.exception_to_unicode(e))
@ -614,7 +613,7 @@ class SwiftTests(object):
exception_caught = False
try:
self.store.add(expected_image_id, image_swift, 0)
except BackendException as e:
except exceptions.BackendException as e:
exception_caught = True
expected_msg = "container %s does not exist in Swift"
expected_msg = expected_msg % expected_container

View File

@ -21,7 +21,7 @@ import uuid
import mock
from oslo_utils import units
from oslo_vmware import api
from oslo_vmware.exceptions import FileNotFoundException
from oslo_vmware import exceptions as vmware_exceptions
from oslo_vmware.objects import datacenter as oslo_datacenter
from oslo_vmware.objects import datastore as oslo_datastore
import six
@ -256,7 +256,7 @@ class TestStore(base.StoreBaseTest,
"dsName=ds1&dcPath=dc1" % FAKE_UUID, conf=self.conf)
with mock.patch.object(self.store.session,
'wait_for_task') as mock_task:
mock_task.side_effect = FileNotFoundException
mock_task.side_effect = vmware_exceptions.FileNotFoundException
self.assertRaises(exceptions.NotFound, self.store.delete, loc)
@mock.patch('oslo_vmware.api.VMwareAPISession')