Use oslo_db.sqlalchemy.test_fixtures
Make use of the newer fixtures in oslo_db.sqlalchemy.test_fixtures which is what was intended to supersede fixtures in oslo_db.sqlalchemy.test_base. Change-Id: Icb88c13336fffb499083197ed864b8e4e45dc241 Closes-Bug: #1797102
This commit is contained in:
parent
f554c61333
commit
7748c754b9
|
@ -32,7 +32,8 @@ import os
|
|||
|
||||
from migrate.versioning import repository
|
||||
import mock
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_fixtures
|
||||
from oslo_db.sqlalchemy import test_migrations
|
||||
from oslo_db.sqlalchemy import utils as db_utils
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -51,6 +52,10 @@ from nova.tests import fixtures as nova_fixtures
|
|||
class NovaAPIModelsSync(test_migrations.ModelsMigrationsSync):
|
||||
"""Test that the models match the database after migrations are run."""
|
||||
|
||||
def setUp(self):
|
||||
super(NovaAPIModelsSync, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
|
||||
def db_sync(self, engine):
|
||||
with mock.patch.object(sa_migration, 'get_engine',
|
||||
return_value=engine):
|
||||
|
@ -122,20 +127,20 @@ class NovaAPIModelsSync(test_migrations.ModelsMigrationsSync):
|
|||
|
||||
|
||||
class TestNovaAPIMigrationsSQLite(NovaAPIModelsSync,
|
||||
test_base.DbTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestNovaAPIMigrationsMySQL(NovaAPIModelsSync,
|
||||
test_base.MySQLOpportunisticTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
pass
|
||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class TestNovaAPIMigrationsPostgreSQL(NovaAPIModelsSync,
|
||||
test_base.PostgreSQLOpportunisticTestCase, test.NoDBTestCase):
|
||||
pass
|
||||
test_fixtures.OpportunisticDBTestMixin, test.NoDBTestCase):
|
||||
FIXTURE = test_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
||||
|
@ -146,6 +151,7 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
|||
# test output.
|
||||
self.useFixture(nova_fixtures.StandardLogging())
|
||||
super(NovaAPIMigrationsWalk, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
|
||||
@property
|
||||
def INIT_VERSION(self):
|
||||
|
@ -722,17 +728,17 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
|||
|
||||
|
||||
class TestNovaAPIMigrationsWalkSQLite(NovaAPIMigrationsWalk,
|
||||
test_base.DbTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestNovaAPIMigrationsWalkMySQL(NovaAPIMigrationsWalk,
|
||||
test_base.MySQLOpportunisticTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
pass
|
||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class TestNovaAPIMigrationsWalkPostgreSQL(NovaAPIMigrationsWalk,
|
||||
test_base.PostgreSQLOpportunisticTestCase, test.NoDBTestCase):
|
||||
pass
|
||||
test_fixtures.OpportunisticDBTestMixin, test.NoDBTestCase):
|
||||
FIXTURE = test_fixtures.PostgresqlOpportunisticFixture
|
||||
|
|
|
@ -27,7 +27,7 @@ import netaddr
|
|||
from oslo_db import api as oslo_db_api
|
||||
from oslo_db import exception as db_exc
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import test_fixtures
|
||||
from oslo_db.sqlalchemy import update_match
|
||||
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||
from oslo_serialization import jsonutils
|
||||
|
@ -8832,7 +8832,9 @@ class RetryOnDeadlockTestCase(test.TestCase):
|
|||
self.assertTrue(call_api())
|
||||
|
||||
|
||||
class TestSqlalchemyTypesRepr(test_base.DbTestCase):
|
||||
class TestSqlalchemyTypesRepr(
|
||||
test_fixtures.OpportunisticDBTestMixin, test.NoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
# NOTE(sdague): the oslo_db base test case completely
|
||||
# invalidates our logging setup, we actually have to do that
|
||||
|
@ -8841,6 +8843,7 @@ class TestSqlalchemyTypesRepr(test_base.DbTestCase):
|
|||
self.useFixture(nova_fixtures.StandardLogging())
|
||||
|
||||
super(TestSqlalchemyTypesRepr, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
meta = MetaData(bind=self.engine)
|
||||
self.table = Table(
|
||||
'cidr_tbl',
|
||||
|
@ -8867,14 +8870,12 @@ class TestSqlalchemyTypesRepr(test_base.DbTestCase):
|
|||
self.assertEqual(addrs[idx][1], row.addr)
|
||||
|
||||
|
||||
class TestMySQLSqlalchemyTypesRepr(TestSqlalchemyTypesRepr,
|
||||
test_base.MySQLOpportunisticTestCase):
|
||||
pass
|
||||
class TestMySQLSqlalchemyTypesRepr(TestSqlalchemyTypesRepr):
|
||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class TestPostgreSQLSqlalchemyTypesRepr(TestSqlalchemyTypesRepr,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
class TestPostgreSQLSqlalchemyTypesRepr(TestSqlalchemyTypesRepr):
|
||||
FIXTURE = test_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class TestDBInstanceTags(test.TestCase):
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_db.sqlalchemy.compat import utils as compat_utils
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import test_fixtures
|
||||
from oslo_db.sqlalchemy import utils as oslodbutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy import Integer, String
|
||||
|
@ -26,6 +28,7 @@ from sqlalchemy.types import UserDefinedType
|
|||
from nova.db.sqlalchemy import api as db
|
||||
from nova.db.sqlalchemy import utils
|
||||
from nova import exception
|
||||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
||||
SA_VERSION = compat_utils.SQLA_VERSION
|
||||
|
@ -44,7 +47,8 @@ class CustomType(UserDefinedType):
|
|||
# a fixture.
|
||||
|
||||
|
||||
class TestMigrationUtilsSQLite(test_base.DbTestCase):
|
||||
class TestMigrationUtilsSQLite(
|
||||
test_fixtures.OpportunisticDBTestMixin, test.NoDBTestCase):
|
||||
"""Class for testing utils that are used in db migrations."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -54,6 +58,7 @@ class TestMigrationUtilsSQLite(test_base.DbTestCase):
|
|||
# test output.
|
||||
self.useFixture(nova_fixtures.StandardLogging())
|
||||
super(TestMigrationUtilsSQLite, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.meta = MetaData(bind=self.engine)
|
||||
|
||||
def test_delete_from_select(self):
|
||||
|
@ -221,11 +226,9 @@ class TestMigrationUtilsSQLite(test_base.DbTestCase):
|
|||
self.engine, table_name=table_name)
|
||||
|
||||
|
||||
class TestMigrationUtilsPostgreSQL(TestMigrationUtilsSQLite,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
class TestMigrationUtilsPostgreSQL(TestMigrationUtilsSQLite):
|
||||
FIXTURE = test_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class TestMigrationUtilsMySQL(TestMigrationUtilsSQLite,
|
||||
test_base.MySQLOpportunisticTestCase):
|
||||
pass
|
||||
class TestMigrationUtilsMySQL(TestMigrationUtilsSQLite):
|
||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||
|
|
|
@ -38,7 +38,8 @@ import os
|
|||
from migrate import UniqueConstraint
|
||||
from migrate.versioning import repository
|
||||
import mock
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_fixtures
|
||||
from oslo_db.sqlalchemy import test_migrations
|
||||
from oslo_db.sqlalchemy import utils as oslodbutils
|
||||
import sqlalchemy
|
||||
|
@ -101,6 +102,7 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
self.useFixture(nova_fixtures.Timeout(
|
||||
os.environ.get('OS_TEST_TIMEOUT', 0),
|
||||
self.TIMEOUT_SCALING_FACTOR))
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
|
||||
def assertColumnExists(self, engine, table_name, column):
|
||||
self.assertTrue(oslodbutils.column_exists(engine, table_name, column),
|
||||
|
@ -1016,14 +1018,16 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
|
||||
|
||||
class TestNovaMigrationsSQLite(NovaMigrationsCheckers,
|
||||
test_base.DbTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
pass
|
||||
|
||||
|
||||
class TestNovaMigrationsMySQL(NovaMigrationsCheckers,
|
||||
test_base.MySQLOpportunisticTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
def test_innodb_tables(self):
|
||||
with mock.patch.object(sa_migration, 'get_engine',
|
||||
return_value=self.migrate_engine):
|
||||
|
@ -1048,9 +1052,9 @@ class TestNovaMigrationsMySQL(NovaMigrationsCheckers,
|
|||
|
||||
|
||||
class TestNovaMigrationsPostgreSQL(NovaMigrationsCheckers,
|
||||
test_base.PostgreSQLOpportunisticTestCase,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test.NoDBTestCase):
|
||||
pass
|
||||
FIXTURE = test_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class ProjectTestCase(test.NoDBTestCase):
|
||||
|
|
Loading…
Reference in New Issue