tests: Use base class for all functional tests
We were not using our own base class for some of the functional tests, which resulted in us missing SQLAlchemy 2.0 issues. Correct this. Change-Id: I921646053c9c68b06df54d206c3d51838c4cafa6 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
f71603d695
commit
d00a9fedd5
|
@ -30,6 +30,8 @@ class TestCase(testtools.TestCase):
|
|||
and establishes the placement database.
|
||||
"""
|
||||
|
||||
USES_DB = True
|
||||
|
||||
def setUp(self):
|
||||
super(TestCase, self).setUp()
|
||||
|
||||
|
@ -37,8 +39,14 @@ class TestCase(testtools.TestCase):
|
|||
self.conf_fixture = self.useFixture(
|
||||
config_fixture.Config(cfg.ConfigOpts()))
|
||||
conf.register_opts(self.conf_fixture.conf)
|
||||
self.placement_db = self.useFixture(fixtures.Database(
|
||||
self.conf_fixture, set_config=True))
|
||||
if self.USES_DB:
|
||||
self.placement_db = self.useFixture(fixtures.Database(
|
||||
self.conf_fixture, set_config=True))
|
||||
else:
|
||||
self.conf_fixture.config(
|
||||
connection='sqlite://',
|
||||
group='placement_database',
|
||||
)
|
||||
self.conf_fixture.conf([], default_config_files=[])
|
||||
|
||||
self.useFixture(policy_fixture.PolicyFixture(self.conf_fixture))
|
||||
|
@ -51,3 +59,7 @@ class TestCase(testtools.TestCase):
|
|||
|
||||
self.context = context.RequestContext()
|
||||
self.context.config = self.conf_fixture.conf
|
||||
|
||||
|
||||
class NoDBTestCase(TestCase):
|
||||
USES_DB = False
|
||||
|
|
|
@ -23,7 +23,6 @@ subdirectory. The test will then use that DB and username/password combo to run
|
|||
the tests.
|
||||
"""
|
||||
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from alembic import script
|
||||
|
@ -32,13 +31,12 @@ from oslo_db.sqlalchemy import test_migrations
|
|||
from oslo_db.sqlalchemy import utils as db_utils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslotest import base as test_base
|
||||
from sqlalchemy import inspect
|
||||
import testtools
|
||||
|
||||
from placement.db.sqlalchemy import migration
|
||||
from placement.db.sqlalchemy import models
|
||||
from placement import db_api
|
||||
from placement.tests.functional import base
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -88,7 +86,7 @@ class WalkVersionsMixin(object):
|
|||
raise
|
||||
|
||||
|
||||
class TestWalkVersions(testtools.TestCase, WalkVersionsMixin):
|
||||
class TestWalkVersions(base.NoDBTestCase, WalkVersionsMixin):
|
||||
def setUp(self):
|
||||
super(TestWalkVersions, self).setUp()
|
||||
self.migration_api = mock.MagicMock()
|
||||
|
@ -301,21 +299,21 @@ class PostgresqlOpportunisticFixture(
|
|||
class TestMigrationsSQLite(MigrationCheckersMixin,
|
||||
WalkVersionsMixin,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
base.NoDBTestCase):
|
||||
FIXTURE = SQLiteOpportunisticFixture
|
||||
|
||||
|
||||
class TestMigrationsMySQL(MigrationCheckersMixin,
|
||||
WalkVersionsMixin,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
base.NoDBTestCase):
|
||||
FIXTURE = MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class TestMigrationsPostgresql(MigrationCheckersMixin,
|
||||
WalkVersionsMixin,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
base.NoDBTestCase):
|
||||
FIXTURE = PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
|
@ -332,17 +330,17 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
|
|||
|
||||
class ModelsMigrationsSyncSqlite(_TestModelsMigrations,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
base.NoDBTestCase):
|
||||
FIXTURE = SQLiteOpportunisticFixture
|
||||
|
||||
|
||||
class ModelsMigrationsSyncMysql(_TestModelsMigrations,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
base.NoDBTestCase):
|
||||
FIXTURE = MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class ModelsMigrationsSyncPostgresql(_TestModelsMigrations,
|
||||
test_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
base.NoDBTestCase):
|
||||
FIXTURE = PostgresqlOpportunisticFixture
|
||||
|
|
Loading…
Reference in New Issue