summaryrefslogtreecommitdiff
path: root/glance_store
diff options
context:
space:
mode:
authorCao Xuan Hoang <hoangcx@vn.fujitsu.com>2016-09-07 16:15:16 +0700
committerCao Xuan Hoang <hoangcx@vn.fujitsu.com>2016-09-07 16:16:16 +0700
commitaffcff2e85ccfa1a02d926f013faec9c6f91c2af (patch)
tree56324b6f634811c5f1d22df245530b1f83125c39 /glance_store
parent33411db05b57f99f604df93e3262ba9fdaa46314 (diff)
downloadglance_store-affcff2e85ccfa1a02d926f013faec9c6f91c2af.tar.gz
Clean imports in code
This patch set modifies lines which are importing objects instead of modules. As per openstack import guide lines, user should import modules in a file not objects. http://docs.openstack.org/developer/hacking/#imports Change-Id: I7525672d64a3bc5df2dc6bdbf19da5b1d6c9dc1e
Diffstat (limited to 'glance_store')
-rw-r--r--glance_store/_drivers/swift/utils.py4
-rw-r--r--glance_store/tests/unit/test_filesystem_store.py29
-rw-r--r--glance_store/tests/unit/test_rbd_store.py14
-rw-r--r--glance_store/tests/unit/test_swift_store.py5
-rw-r--r--glance_store/tests/unit/test_vmware_store.py4
5 files changed, 27 insertions, 29 deletions
diff --git a/glance_store/_drivers/swift/utils.py b/glance_store/_drivers/swift/utils.py
index 11ddce4..642f787 100644
--- a/glance_store/_drivers/swift/utils.py
+++ b/glance_store/_drivers/swift/utils.py
@@ -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__)
diff --git a/glance_store/tests/unit/test_filesystem_store.py b/glance_store/tests/unit/test_filesystem_store.py
index 258a81e..222d760 100644
--- a/glance_store/tests/unit/test_filesystem_store.py
+++ b/glance_store/tests/unit/test_filesystem_store.py
@@ -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
diff --git a/glance_store/tests/unit/test_rbd_store.py b/glance_store/tests/unit/test_rbd_store.py
index d51237e..b4294aa 100644
--- a/glance_store/tests/unit/test_rbd_store.py
+++ b/glance_store/tests/unit/test_rbd_store.py
@@ -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)
diff --git a/glance_store/tests/unit/test_swift_store.py b/glance_store/tests/unit/test_swift_store.py
index e30febe..f82376d 100644
--- a/glance_store/tests/unit/test_swift_store.py
+++ b/glance_store/tests/unit/test_swift_store.py
@@ -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
@@ -483,7 +482,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))
@@ -615,7 +614,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
diff --git a/glance_store/tests/unit/test_vmware_store.py b/glance_store/tests/unit/test_vmware_store.py
index c77b9fd..03964bd 100644
--- a/glance_store/tests/unit/test_vmware_store.py
+++ b/glance_store/tests/unit/test_vmware_store.py
@@ -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')