Merge "Rearrange db tests in prep for testr."
This commit is contained in:
commit
fc20487d26
@ -61,18 +61,16 @@ def build_image_fixture(**kwargs):
|
||||
|
||||
|
||||
class TestDriver(base.IsolatedUnitTest):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDriver, self).setUp()
|
||||
self.adm_context = context.RequestContext(is_admin=True)
|
||||
self.context = context.RequestContext(is_admin=False)
|
||||
self.db_api = db_tests.get_db(self.config)
|
||||
db_tests.reset_db(self.db_api)
|
||||
self.fixtures = self.build_image_fixtures()
|
||||
self.create_images(self.fixtures)
|
||||
super(TestDriver, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
timeutils.clear_time_override()
|
||||
super(TestDriver, self).tearDown()
|
||||
self.addCleanup(timeutils.clear_time_override)
|
||||
|
||||
def build_image_fixtures(self):
|
||||
dt1 = timeutils.utcnow()
|
||||
@ -103,6 +101,9 @@ class TestDriver(base.IsolatedUnitTest):
|
||||
for fixture in images:
|
||||
self.db_api.image_create(self.adm_context, fixture)
|
||||
|
||||
|
||||
class DriverTests(object):
|
||||
|
||||
def test_image_create_requires_status(self):
|
||||
fixture = {'name': 'mark', 'size': 12}
|
||||
self.assertRaises(exception.Invalid,
|
||||
@ -630,6 +631,9 @@ class TestVisibility(base.IsolatedUnitTest):
|
||||
for fixture in images:
|
||||
self.db_api.image_create(self.admin_context, fixture)
|
||||
|
||||
|
||||
class VisibilityTests(object):
|
||||
|
||||
def test_unknown_admin_sees_all(self):
|
||||
images = self.db_api.image_get_all(self.admin_none_context)
|
||||
self.assertEquals(len(images), 8)
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
import glance.db.simple.api
|
||||
import glance.tests.functional.db as db_tests
|
||||
from glance.tests.functional.db import base
|
||||
|
||||
|
||||
def get_db(config):
|
||||
@ -26,15 +27,17 @@ def reset_db(db_api):
|
||||
db_api.reset()
|
||||
|
||||
|
||||
def setUpModule():
|
||||
"""Stub in get_db and reset_db for testing the simple db api."""
|
||||
db_tests.load(get_db, reset_db)
|
||||
class TestSimpleDriver(base.TestDriver, base.DriverTests):
|
||||
|
||||
def setUp(self):
|
||||
db_tests.load(get_db, reset_db)
|
||||
super(TestSimpleDriver, self).setUp()
|
||||
self.addCleanup(db_tests.reset)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
"""Reset get_db and reset_db for cleanliness."""
|
||||
db_tests.reset()
|
||||
class TestSimpleVisibility(base.TestVisibility, base.VisibilityTests):
|
||||
|
||||
|
||||
#NOTE(markwash): Pull in all the base test cases
|
||||
from glance.tests.functional.db.base import *
|
||||
def setUp(self):
|
||||
db_tests.load(get_db, reset_db)
|
||||
super(TestSimpleVisibility, self).setUp()
|
||||
self.addCleanup(db_tests.reset)
|
||||
|
@ -17,6 +17,7 @@
|
||||
import glance.db.sqlalchemy.api
|
||||
from glance.db.sqlalchemy import models as db_models
|
||||
import glance.tests.functional.db as db_tests
|
||||
from glance.tests.functional.db import base
|
||||
|
||||
|
||||
def get_db(config):
|
||||
@ -31,15 +32,17 @@ def reset_db(db_api):
|
||||
db_models.register_models(db_api._ENGINE)
|
||||
|
||||
|
||||
def setUpModule():
|
||||
"""Stub in get_db and reset_db for testing the sqlalchemy db api."""
|
||||
db_tests.load(get_db, reset_db)
|
||||
class TestSqlAlchemyDriver(base.TestDriver, base.DriverTests):
|
||||
|
||||
def setUp(self):
|
||||
db_tests.load(get_db, reset_db)
|
||||
super(TestSqlAlchemyDriver, self).setUp()
|
||||
self.addCleanup(db_tests.reset)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
"""Reset get_db and reset_db for cleanliness."""
|
||||
db_tests.reset()
|
||||
class TestSqlAlchemyVisibility(base.TestVisibility, base.VisibilityTests):
|
||||
|
||||
|
||||
#NOTE(markwash): Pull in all the base test cases
|
||||
from glance.tests.functional.db.base import *
|
||||
def setUp(self):
|
||||
db_tests.load(get_db, reset_db)
|
||||
super(TestSqlAlchemyVisibility, self).setUp()
|
||||
self.addCleanup(db_tests.reset)
|
||||
|
Loading…
Reference in New Issue
Block a user