Merge "Provide extra parameter for FakeDB"
This commit is contained in:
commit
d2409ec7b3
@ -125,8 +125,7 @@ class TestImageRepo(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestImageRepo, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.context = glance.context.RequestContext(
|
||||
user=USER1, tenant=TENANT1)
|
||||
self.image_repo = glance.db.ImageRepo(self.context, self.db)
|
||||
@ -135,7 +134,6 @@ class TestImageRepo(test_utils.BaseTestCase):
|
||||
self._create_image_members()
|
||||
|
||||
def _create_images(self):
|
||||
self.db.reset()
|
||||
self.images = [
|
||||
_db_fixture(UUID1, owner=TENANT1, checksum=CHECKSUM,
|
||||
name='1', size=256,
|
||||
@ -393,8 +391,7 @@ class TestImageRepo(test_utils.BaseTestCase):
|
||||
class TestEncryptedLocations(test_utils.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestEncryptedLocations, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.context = glance.context.RequestContext(
|
||||
user=USER1, tenant=TENANT1)
|
||||
self.image_repo = glance.db.ImageRepo(self.context, self.db)
|
||||
@ -472,8 +469,7 @@ class TestImageMemberRepo(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestImageMemberRepo, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.context = glance.context.RequestContext(
|
||||
user=USER1, tenant=TENANT1)
|
||||
self.image_repo = glance.db.ImageRepo(self.context, self.db)
|
||||
@ -596,8 +592,7 @@ class TestTaskRepo(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTaskRepo, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.context = glance.context.RequestContext(user=USER1,
|
||||
tenant=TENANT1)
|
||||
self.task_repo = glance.db.TaskRepo(self.context, self.db)
|
||||
@ -608,7 +603,6 @@ class TestTaskRepo(test_utils.BaseTestCase):
|
||||
self._create_tasks()
|
||||
|
||||
def _create_tasks(self):
|
||||
self.db.reset()
|
||||
self.tasks = [
|
||||
_db_task_fixture(UUID1, type='import', status='pending',
|
||||
input=self.fake_task_input,
|
||||
|
@ -128,8 +128,7 @@ class TestMetadefRepo(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMetadefRepo, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.context = glance.context.RequestContext(user=USER1,
|
||||
tenant=TENANT1)
|
||||
self.namespace_repo = glance.db.MetadefNamespaceRepo(self.context,
|
||||
@ -154,7 +153,6 @@ class TestMetadefRepo(test_utils.BaseTestCase):
|
||||
self._create_resource_types()
|
||||
|
||||
def _create_namespaces(self):
|
||||
self.db.reset()
|
||||
self.namespaces = [
|
||||
_db_namespace_fixture(namespace=NAMESPACE1,
|
||||
display_name='1',
|
||||
|
@ -167,8 +167,7 @@ def _db_tag_fixture(name, **kwargs):
|
||||
class TestImageLoaderPlugin(test_utils.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestImageLoaderPlugin, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
|
||||
self._create_images()
|
||||
|
||||
@ -396,8 +395,7 @@ class TestImageLoaderPlugin(test_utils.BaseTestCase):
|
||||
class TestMetadefLoaderPlugin(test_utils.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestMetadefLoaderPlugin, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db.reset()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
|
||||
self._create_resource_types()
|
||||
self._create_namespaces()
|
||||
|
@ -85,9 +85,10 @@ def fake_get_size_from_backend(uri, context=None):
|
||||
|
||||
class FakeDB(object):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, initialize=True):
|
||||
self.reset()
|
||||
self.init_db()
|
||||
if initialize:
|
||||
self.init_db()
|
||||
|
||||
@staticmethod
|
||||
def init_db():
|
||||
|
@ -56,7 +56,7 @@ def _db_fixture(id, **kwargs):
|
||||
class TestImageActionsController(base.IsolatedUnitTest):
|
||||
def setUp(self):
|
||||
super(TestImageActionsController, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.policy = unit_test_utils.FakePolicyEnforcer()
|
||||
self.notifier = unit_test_utils.FakeNotifier()
|
||||
self.store = unit_test_utils.FakeStoreAPI()
|
||||
@ -84,7 +84,6 @@ class TestImageActionsController(base.IsolatedUnitTest):
|
||||
return context
|
||||
|
||||
def _create_image(self, status):
|
||||
self.db.reset()
|
||||
self.images = [
|
||||
_db_fixture(UUID1, owner=TENANT1, checksum=CHKSUM,
|
||||
name='1', size=256, virtual_size=1024,
|
||||
|
@ -90,7 +90,7 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestImageMembersController, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.store = unit_test_utils.FakeStoreAPI()
|
||||
self.policy = unit_test_utils.FakePolicyEnforcer()
|
||||
self.notifier = unit_test_utils.FakeNotifier()
|
||||
@ -110,7 +110,6 @@ class TestImageMembersController(test_utils.BaseTestCase):
|
||||
glance_store.create_stores()
|
||||
|
||||
def _create_images(self):
|
||||
self.db.reset()
|
||||
self.images = [
|
||||
_db_fixture(UUID1, owner=TENANT1, name='1', size=256,
|
||||
is_public=True,
|
||||
|
@ -117,7 +117,7 @@ class TestImagesController(base.IsolatedUnitTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestImagesController, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.policy = unit_test_utils.FakePolicyEnforcer()
|
||||
self.notifier = unit_test_utils.FakeNotifier()
|
||||
self.store = unit_test_utils.FakeStoreAPI()
|
||||
@ -134,7 +134,6 @@ class TestImagesController(base.IsolatedUnitTest):
|
||||
store.create_stores()
|
||||
|
||||
def _create_images(self):
|
||||
self.db.reset()
|
||||
self.images = [
|
||||
_db_fixture(UUID1, owner=TENANT1, checksum=CHKSUM,
|
||||
name='1', size=256, virtual_size=1024,
|
||||
|
@ -140,7 +140,7 @@ class TestMetadefsControllers(base.IsolatedUnitTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestMetadefsControllers, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.policy = unit_test_utils.FakePolicyEnforcer()
|
||||
self.notifier = unit_test_utils.FakeNotifier()
|
||||
self._create_namespaces()
|
||||
@ -161,7 +161,6 @@ class TestMetadefsControllers(base.IsolatedUnitTest):
|
||||
self.db, self.policy, self.notifier)
|
||||
|
||||
def _create_namespaces(self):
|
||||
self.db.reset()
|
||||
req = unit_test_utils.get_fake_request()
|
||||
self.namespaces = [
|
||||
_db_namespace_fixture(NAMESPACE1, owner=TENANT1,
|
||||
|
@ -87,7 +87,7 @@ class TestTasksController(test_utils.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTasksController, self).setUp()
|
||||
self.db = unit_test_utils.FakeDB()
|
||||
self.db = unit_test_utils.FakeDB(initialize=False)
|
||||
self.policy = unit_test_utils.FakePolicyEnforcer()
|
||||
self.notifier = unit_test_utils.FakeNotifier()
|
||||
self.store = unit_test_utils.FakeStoreAPI()
|
||||
@ -98,7 +98,6 @@ class TestTasksController(test_utils.BaseTestCase):
|
||||
self.store)
|
||||
|
||||
def _create_tasks(self):
|
||||
self.db.reset()
|
||||
now = timeutils.utcnow()
|
||||
times = [now + datetime.timedelta(seconds=5 * i) for i in range(4)]
|
||||
self.tasks = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user