tests: Use common base class
The final step in cleaning up our many base classes. This will allow us to do things consistently across the test suite in future changes. Change-Id: I0bf663fdfd3c8be93e5658493e221d0a7db78832 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
538e0a23ab
commit
a6007a98b1
@ -18,7 +18,7 @@ import debtcollector
|
|||||||
from oslo_db.sqlalchemy import enginefacade
|
from oslo_db.sqlalchemy import enginefacade
|
||||||
from oslo_db.sqlalchemy.test_base import backend_specific # noqa
|
from oslo_db.sqlalchemy.test_base import backend_specific # noqa
|
||||||
from oslo_db.sqlalchemy import test_fixtures as db_fixtures
|
from oslo_db.sqlalchemy import test_fixtures as db_fixtures
|
||||||
from oslotest import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
|
|
||||||
@enginefacade.transaction_context_provider
|
@enginefacade.transaction_context_provider
|
||||||
@ -62,7 +62,8 @@ class PostgreSQLOpportunisticTestCase(DbTestCase):
|
|||||||
# make use of oslo_db.sqlalchemy.test_fixtures directly.
|
# make use of oslo_db.sqlalchemy.test_fixtures directly.
|
||||||
|
|
||||||
class _DbTestCase(
|
class _DbTestCase(
|
||||||
db_fixtures.OpportunisticDBTestMixin, test_base.BaseTestCase):
|
db_fixtures.OpportunisticDBTestMixin, test_base.BaseTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(_DbTestCase, self).setUp()
|
super(_DbTestCase, self).setUp()
|
||||||
|
@ -21,7 +21,6 @@ import warnings
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_context import context as oslo_context
|
from oslo_context import context as oslo_context
|
||||||
from oslotest import base as oslo_test_base
|
|
||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy import Integer
|
from sqlalchemy import Integer
|
||||||
from sqlalchemy import MetaData
|
from sqlalchemy import MetaData
|
||||||
@ -36,10 +35,10 @@ from oslo_db import options
|
|||||||
from oslo_db.sqlalchemy import enginefacade
|
from oslo_db.sqlalchemy import enginefacade
|
||||||
from oslo_db.sqlalchemy import engines as oslo_engines
|
from oslo_db.sqlalchemy import engines as oslo_engines
|
||||||
from oslo_db.sqlalchemy import orm
|
from oslo_db.sqlalchemy import orm
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
from oslo_db import warning
|
from oslo_db import warning
|
||||||
|
|
||||||
|
|
||||||
enginefacade.transaction_context_provider(oslo_context.RequestContext)
|
enginefacade.transaction_context_provider(oslo_context.RequestContext)
|
||||||
|
|
||||||
|
|
||||||
@ -92,7 +91,7 @@ class AssertDataSource(collections.namedtuple(
|
|||||||
assert False, "Unknown constant: %s" % const
|
assert False, "Unknown constant: %s" % const
|
||||||
|
|
||||||
|
|
||||||
class MockFacadeTest(oslo_test_base.BaseTestCase):
|
class MockFacadeTest(test_base.BaseTestCase):
|
||||||
"""test by applying mocks to internal call-points.
|
"""test by applying mocks to internal call-points.
|
||||||
|
|
||||||
This applies mocks to
|
This applies mocks to
|
||||||
@ -1186,7 +1185,7 @@ class MockFacadeTest(oslo_test_base.BaseTestCase):
|
|||||||
session.execute("test")
|
session.execute("test")
|
||||||
|
|
||||||
|
|
||||||
class PatchFactoryTest(oslo_test_base.BaseTestCase):
|
class PatchFactoryTest(test_base.BaseTestCase):
|
||||||
|
|
||||||
def test_patch_manager(self):
|
def test_patch_manager(self):
|
||||||
normal_mgr = enginefacade.transaction_context()
|
normal_mgr = enginefacade.transaction_context()
|
||||||
@ -1396,7 +1395,7 @@ class AsyncReaderWSlaveMockFacadeTest(MockFacadeTest):
|
|||||||
slave_uri = 'some_slave_connection'
|
slave_uri = 'some_slave_connection'
|
||||||
|
|
||||||
|
|
||||||
class LegacyIntegrationtest(test_base._DbTestCase):
|
class LegacyIntegrationtest(db_test_base._DbTestCase):
|
||||||
|
|
||||||
def test_legacy_integration(self):
|
def test_legacy_integration(self):
|
||||||
legacy_facade = enginefacade.get_legacy_facade()
|
legacy_facade = enginefacade.get_legacy_facade()
|
||||||
@ -1454,7 +1453,7 @@ class LegacyIntegrationtest(test_base._DbTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ThreadingTest(test_base._DbTestCase):
|
class ThreadingTest(db_test_base._DbTestCase):
|
||||||
"""Test copy/pickle on new threads using real connections and sessions."""
|
"""Test copy/pickle on new threads using real connections and sessions."""
|
||||||
|
|
||||||
def _assert_ctx_connection(self, context, connection):
|
def _assert_ctx_connection(self, context, connection):
|
||||||
@ -1647,7 +1646,7 @@ class ThreadingTest(test_base._DbTestCase):
|
|||||||
assert session is not session2
|
assert session is not session2
|
||||||
|
|
||||||
|
|
||||||
class LiveFacadeTest(test_base._DbTestCase):
|
class LiveFacadeTest(db_test_base._DbTestCase):
|
||||||
"""test using live SQL with test-provisioned databases.
|
"""test using live SQL with test-provisioned databases.
|
||||||
|
|
||||||
Several of these tests require that multiple transactions run
|
Several of these tests require that multiple transactions run
|
||||||
@ -1809,7 +1808,7 @@ class LiveFacadeTest(test_base._DbTestCase):
|
|||||||
session.query(self.User.name).scalar()
|
session.query(self.User.name).scalar()
|
||||||
)
|
)
|
||||||
|
|
||||||
@test_base.backend_specific("postgresql", "mysql")
|
@db_test_base.backend_specific("postgresql", "mysql")
|
||||||
def test_external_session_transaction(self):
|
def test_external_session_transaction(self):
|
||||||
context = oslo_context.RequestContext()
|
context = oslo_context.RequestContext()
|
||||||
with enginefacade.writer.using(context) as session:
|
with enginefacade.writer.using(context) as session:
|
||||||
@ -1916,7 +1915,7 @@ class LiveFacadeTest(test_base._DbTestCase):
|
|||||||
self.User.name).order_by(self.User.name).all()
|
self.User.name).order_by(self.User.name).all()
|
||||||
)
|
)
|
||||||
|
|
||||||
@test_base.backend_specific("postgresql", "mysql")
|
@db_test_base.backend_specific("postgresql", "mysql")
|
||||||
def test_external_session_transaction_decorator(self):
|
def test_external_session_transaction_decorator(self):
|
||||||
context = oslo_context.RequestContext()
|
context = oslo_context.RequestContext()
|
||||||
|
|
||||||
@ -1964,7 +1963,7 @@ class LiveFacadeTest(test_base._DbTestCase):
|
|||||||
self.User.name).order_by(self.User.name).all()
|
self.User.name).order_by(self.User.name).all()
|
||||||
)
|
)
|
||||||
|
|
||||||
@test_base.backend_specific("postgresql", "mysql")
|
@db_test_base.backend_specific("postgresql", "mysql")
|
||||||
def test_external_connection_transaction(self):
|
def test_external_connection_transaction(self):
|
||||||
context = oslo_context.RequestContext()
|
context = oslo_context.RequestContext()
|
||||||
with enginefacade.writer.connection.using(context) as connection:
|
with enginefacade.writer.connection.using(context) as connection:
|
||||||
@ -2001,7 +2000,7 @@ class LiveFacadeTest(test_base._DbTestCase):
|
|||||||
self.User.name).order_by(self.User.name).all()
|
self.User.name).order_by(self.User.name).all()
|
||||||
)
|
)
|
||||||
|
|
||||||
@test_base.backend_specific("postgresql", "mysql")
|
@db_test_base.backend_specific("postgresql", "mysql")
|
||||||
def test_external_writer_in_reader(self):
|
def test_external_writer_in_reader(self):
|
||||||
context = oslo_context.RequestContext()
|
context = oslo_context.RequestContext()
|
||||||
with enginefacade.reader.using(context) as session:
|
with enginefacade.reader.using(context) as session:
|
||||||
@ -2188,16 +2187,18 @@ class LiveFacadeTest(test_base._DbTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class MySQLLiveFacadeTest(
|
class MySQLLiveFacadeTest(
|
||||||
test_base._MySQLOpportunisticTestCase, LiveFacadeTest):
|
db_test_base._MySQLOpportunisticTestCase, LiveFacadeTest,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PGLiveFacadeTest(
|
class PGLiveFacadeTest(
|
||||||
test_base._PostgreSQLOpportunisticTestCase, LiveFacadeTest):
|
db_test_base._PostgreSQLOpportunisticTestCase, LiveFacadeTest,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ConfigOptionsTest(oslo_test_base.BaseTestCase):
|
class ConfigOptionsTest(test_base.BaseTestCase):
|
||||||
def test_all_options(self):
|
def test_all_options(self):
|
||||||
"""test that everything in CONF.database.iteritems() is accepted.
|
"""test that everything in CONF.database.iteritems() is accepted.
|
||||||
|
|
||||||
@ -2242,7 +2243,7 @@ class ConfigOptionsTest(oslo_test_base.BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestTransactionFactoryCallback(oslo_test_base.BaseTestCase):
|
class TestTransactionFactoryCallback(test_base.BaseTestCase):
|
||||||
|
|
||||||
def test_setup_for_connection_called_with_profiler(self):
|
def test_setup_for_connection_called_with_profiler(self):
|
||||||
context_manager = enginefacade.transaction_context()
|
context_manager = enginefacade.transaction_context()
|
||||||
|
@ -18,7 +18,6 @@ import contextlib
|
|||||||
import itertools
|
import itertools
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from oslotest import base as oslo_test_base
|
|
||||||
import sqlalchemy as sqla
|
import sqlalchemy as sqla
|
||||||
from sqlalchemy.engine import url as sqla_url
|
from sqlalchemy.engine import url as sqla_url
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
@ -29,7 +28,8 @@ from sqlalchemy.orm import mapper
|
|||||||
from oslo_db import exception
|
from oslo_db import exception
|
||||||
from oslo_db.sqlalchemy import engines
|
from oslo_db.sqlalchemy import engines
|
||||||
from oslo_db.sqlalchemy import exc_filters
|
from oslo_db.sqlalchemy import exc_filters
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
from oslo_db.tests import utils as test_utils
|
from oslo_db.tests import utils as test_utils
|
||||||
|
|
||||||
_TABLE_NAME = '__tmp__test__tmp__'
|
_TABLE_NAME = '__tmp__test__tmp__'
|
||||||
@ -68,7 +68,7 @@ class _SQLAExceptionMatcher(object):
|
|||||||
self.assertEqual(sql, exc.statement)
|
self.assertEqual(sql, exc.statement)
|
||||||
|
|
||||||
|
|
||||||
class TestsExceptionFilter(_SQLAExceptionMatcher, oslo_test_base.BaseTestCase):
|
class TestsExceptionFilter(_SQLAExceptionMatcher, test_base.BaseTestCase):
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
"""DBAPI base error.
|
"""DBAPI base error.
|
||||||
@ -245,8 +245,9 @@ class TestFallthroughsAndNonDBAPI(TestsExceptionFilter):
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentConstraint(
|
class TestNonExistentConstraint(
|
||||||
_SQLAExceptionMatcher,
|
_SQLAExceptionMatcher,
|
||||||
test_base._DbTestCase):
|
db_test_base._DbTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNonExistentConstraint, self).setUp()
|
super(TestNonExistentConstraint, self).setUp()
|
||||||
@ -263,8 +264,9 @@ class TestNonExistentConstraint(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentConstraintPostgreSQL(
|
class TestNonExistentConstraintPostgreSQL(
|
||||||
TestNonExistentConstraint,
|
TestNonExistentConstraint,
|
||||||
test_base._PostgreSQLOpportunisticTestCase):
|
db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -287,8 +289,9 @@ class TestNonExistentConstraintPostgreSQL(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentConstraintMySQL(
|
class TestNonExistentConstraintMySQL(
|
||||||
TestNonExistentConstraint,
|
TestNonExistentConstraint,
|
||||||
test_base._MySQLOpportunisticTestCase):
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -311,8 +314,9 @@ class TestNonExistentConstraintMySQL(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentTable(
|
class TestNonExistentTable(
|
||||||
_SQLAExceptionMatcher,
|
_SQLAExceptionMatcher,
|
||||||
test_base._DbTestCase):
|
db_test_base._DbTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNonExistentTable, self).setUp()
|
super(TestNonExistentTable, self).setUp()
|
||||||
@ -342,8 +346,9 @@ class TestNonExistentTable(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentTablePostgreSQL(
|
class TestNonExistentTablePostgreSQL(
|
||||||
TestNonExistentTable,
|
TestNonExistentTable,
|
||||||
test_base._PostgreSQLOpportunisticTestCase):
|
db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -361,8 +366,9 @@ class TestNonExistentTablePostgreSQL(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentTableMySQL(
|
class TestNonExistentTableMySQL(
|
||||||
TestNonExistentTable,
|
TestNonExistentTable,
|
||||||
test_base._MySQLOpportunisticTestCase):
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -379,8 +385,9 @@ class TestNonExistentTableMySQL(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentDatabase(
|
class TestNonExistentDatabase(
|
||||||
_SQLAExceptionMatcher,
|
_SQLAExceptionMatcher,
|
||||||
test_base._DbTestCase):
|
db_test_base._DbTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestNonExistentDatabase, self).setUp()
|
super(TestNonExistentDatabase, self).setUp()
|
||||||
@ -413,8 +420,9 @@ class TestNonExistentDatabase(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentDatabaseMySQL(
|
class TestNonExistentDatabaseMySQL(
|
||||||
TestNonExistentDatabase,
|
TestNonExistentDatabase,
|
||||||
test_base._MySQLOpportunisticTestCase):
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -432,8 +440,9 @@ class TestNonExistentDatabaseMySQL(
|
|||||||
|
|
||||||
|
|
||||||
class TestNonExistentDatabasePostgreSQL(
|
class TestNonExistentDatabasePostgreSQL(
|
||||||
TestNonExistentDatabase,
|
TestNonExistentDatabase,
|
||||||
test_base._PostgreSQLOpportunisticTestCase):
|
db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -449,7 +458,9 @@ class TestNonExistentDatabasePostgreSQL(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestReferenceErrorSQLite(_SQLAExceptionMatcher, test_base._DbTestCase):
|
class TestReferenceErrorSQLite(
|
||||||
|
_SQLAExceptionMatcher, db_test_base._DbTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestReferenceErrorSQLite, self).setUp()
|
super(TestReferenceErrorSQLite, self).setUp()
|
||||||
@ -522,8 +533,10 @@ class TestReferenceErrorSQLite(_SQLAExceptionMatcher, test_base._DbTestCase):
|
|||||||
self.assertIsNone(matched.key_table)
|
self.assertIsNone(matched.key_table)
|
||||||
|
|
||||||
|
|
||||||
class TestReferenceErrorPostgreSQL(TestReferenceErrorSQLite,
|
class TestReferenceErrorPostgreSQL(
|
||||||
test_base._PostgreSQLOpportunisticTestCase):
|
TestReferenceErrorSQLite,
|
||||||
|
db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
params = {'id': 1, 'foo_id': 2}
|
params = {'id': 1, 'foo_id': 2}
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
@ -573,8 +586,10 @@ class TestReferenceErrorPostgreSQL(TestReferenceErrorSQLite,
|
|||||||
self.assertEqual("resource_entity", matched.key_table)
|
self.assertEqual("resource_entity", matched.key_table)
|
||||||
|
|
||||||
|
|
||||||
class TestReferenceErrorMySQL(TestReferenceErrorSQLite,
|
class TestReferenceErrorMySQL(
|
||||||
test_base._MySQLOpportunisticTestCase):
|
TestReferenceErrorSQLite,
|
||||||
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
def test_raise(self):
|
def test_raise(self):
|
||||||
matched = self.assertRaises(
|
matched = self.assertRaises(
|
||||||
exception.DBReferenceError,
|
exception.DBReferenceError,
|
||||||
@ -635,7 +650,9 @@ class TestReferenceErrorMySQL(TestReferenceErrorSQLite,
|
|||||||
self.assertEqual("resource_foo", matched.key_table)
|
self.assertEqual("resource_foo", matched.key_table)
|
||||||
|
|
||||||
|
|
||||||
class TestExceptionCauseMySQLSavepoint(test_base._MySQLOpportunisticTestCase):
|
class TestExceptionCauseMySQLSavepoint(
|
||||||
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestExceptionCauseMySQLSavepoint, self).setUp()
|
super(TestExceptionCauseMySQLSavepoint, self).setUp()
|
||||||
|
|
||||||
@ -1011,7 +1028,7 @@ class TestDataError(TestsExceptionFilter):
|
|||||||
self.DataError)
|
self.DataError)
|
||||||
|
|
||||||
|
|
||||||
class IntegrationTest(test_base._DbTestCase):
|
class IntegrationTest(db_test_base._DbTestCase):
|
||||||
"""Test an actual error-raising round trips against the database."""
|
"""Test an actual error-raising round trips against the database."""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -21,12 +21,12 @@ from oslo_db.sqlalchemy import enginefacade
|
|||||||
from oslo_db.sqlalchemy import provision
|
from oslo_db.sqlalchemy import provision
|
||||||
from oslo_db.sqlalchemy import test_base as legacy_test_base
|
from oslo_db.sqlalchemy import test_base as legacy_test_base
|
||||||
from oslo_db.sqlalchemy import test_fixtures
|
from oslo_db.sqlalchemy import test_fixtures
|
||||||
from oslotest import base as oslo_test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
start_dir = os.path.dirname(__file__)
|
start_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
|
||||||
class BackendSkipTest(oslo_test_base.BaseTestCase):
|
class BackendSkipTest(test_base.BaseTestCase):
|
||||||
|
|
||||||
def test_skip_no_dbapi(self):
|
def test_skip_no_dbapi(self):
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ class BackendSkipTest(oslo_test_base.BaseTestCase):
|
|||||||
DRIVER = 'postgresql'
|
DRIVER = 'postgresql'
|
||||||
|
|
||||||
class SomeTest(test_fixtures.OpportunisticDBTestMixin,
|
class SomeTest(test_fixtures.OpportunisticDBTestMixin,
|
||||||
oslo_test_base.BaseTestCase):
|
test_base.BaseTestCase):
|
||||||
FIXTURE = FakeDatabaseOpportunisticFixture
|
FIXTURE = FakeDatabaseOpportunisticFixture
|
||||||
|
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
@ -77,7 +77,7 @@ class BackendSkipTest(oslo_test_base.BaseTestCase):
|
|||||||
DRIVER = 'postgresql+nosuchdbapi'
|
DRIVER = 'postgresql+nosuchdbapi'
|
||||||
|
|
||||||
class SomeTest(test_fixtures.OpportunisticDBTestMixin,
|
class SomeTest(test_fixtures.OpportunisticDBTestMixin,
|
||||||
oslo_test_base.BaseTestCase):
|
test_base.BaseTestCase):
|
||||||
|
|
||||||
FIXTURE = FakeDatabaseOpportunisticFixture
|
FIXTURE = FakeDatabaseOpportunisticFixture
|
||||||
|
|
||||||
@ -99,7 +99,8 @@ class BackendSkipTest(oslo_test_base.BaseTestCase):
|
|||||||
def test_skip_no_dbapi_legacy(self):
|
def test_skip_no_dbapi_legacy(self):
|
||||||
|
|
||||||
class FakeDatabaseOpportunisticFixture(
|
class FakeDatabaseOpportunisticFixture(
|
||||||
legacy_test_base.DbFixture):
|
legacy_test_base.DbFixture,
|
||||||
|
):
|
||||||
DRIVER = 'postgresql'
|
DRIVER = 'postgresql'
|
||||||
|
|
||||||
class SomeTest(legacy_test_base.DbTestCase):
|
class SomeTest(legacy_test_base.DbTestCase):
|
||||||
@ -140,7 +141,8 @@ class BackendSkipTest(oslo_test_base.BaseTestCase):
|
|||||||
def test_skip_no_such_backend_legacy(self):
|
def test_skip_no_such_backend_legacy(self):
|
||||||
|
|
||||||
class FakeDatabaseOpportunisticFixture(
|
class FakeDatabaseOpportunisticFixture(
|
||||||
legacy_test_base.DbFixture):
|
legacy_test_base.DbFixture,
|
||||||
|
):
|
||||||
DRIVER = 'postgresql+nosuchdbapi'
|
DRIVER = 'postgresql+nosuchdbapi'
|
||||||
|
|
||||||
class SomeTest(legacy_test_base.DbTestCase):
|
class SomeTest(legacy_test_base.DbTestCase):
|
||||||
@ -163,7 +165,7 @@ class BackendSkipTest(oslo_test_base.BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class EnginefacadeIntegrationTest(oslo_test_base.BaseTestCase):
|
class EnginefacadeIntegrationTest(test_base.BaseTestCase):
|
||||||
def test_db_fixture(self):
|
def test_db_fixture(self):
|
||||||
normal_mgr = enginefacade.transaction_context()
|
normal_mgr = enginefacade.transaction_context()
|
||||||
normal_mgr.configure(
|
normal_mgr.configure(
|
||||||
@ -204,7 +206,7 @@ class EnginefacadeIntegrationTest(oslo_test_base.BaseTestCase):
|
|||||||
self.assertFalse(normal_mgr._factory._started)
|
self.assertFalse(normal_mgr._factory._started)
|
||||||
|
|
||||||
|
|
||||||
class LegacyBaseClassTest(oslo_test_base.BaseTestCase):
|
class LegacyBaseClassTest(test_base.BaseTestCase):
|
||||||
def test_new_db_is_provisioned_by_default_pg(self):
|
def test_new_db_is_provisioned_by_default_pg(self):
|
||||||
self._test_new_db_is_provisioned_by_default(
|
self._test_new_db_is_provisioned_by_default(
|
||||||
legacy_test_base.PostgreSQLOpportunisticTestCase
|
legacy_test_base.PostgreSQLOpportunisticTestCase
|
||||||
|
@ -9,16 +9,17 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import alembic
|
import alembic
|
||||||
from oslotest import base as test_base
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from oslo_db import exception
|
from oslo_db import exception
|
||||||
from oslo_db.sqlalchemy.migration_cli import ext_alembic
|
from oslo_db.sqlalchemy.migration_cli import ext_alembic
|
||||||
from oslo_db.sqlalchemy.migration_cli import ext_migrate
|
from oslo_db.sqlalchemy.migration_cli import ext_migrate
|
||||||
from oslo_db.sqlalchemy.migration_cli import manager
|
from oslo_db.sqlalchemy.migration_cli import manager
|
||||||
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
|
|
||||||
class MockWithCmp(mock.MagicMock):
|
class MockWithCmp(mock.MagicMock):
|
||||||
|
@ -18,16 +18,16 @@ from unittest import mock
|
|||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from migrate.versioning import api as versioning_api
|
from migrate.versioning import api as versioning_api
|
||||||
from oslotest import base as test
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
import sqlalchemy.ext.declarative as sa_decl
|
import sqlalchemy.ext.declarative as sa_decl
|
||||||
|
|
||||||
from oslo_db import exception as exc
|
from oslo_db import exception as exc
|
||||||
from oslo_db.sqlalchemy import test_migrations as migrate
|
from oslo_db.sqlalchemy import test_migrations as migrate
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
|
|
||||||
|
|
||||||
class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
|
class TestWalkVersions(test_base.BaseTestCase, migrate.WalkVersionsMixin):
|
||||||
migration_api = mock.MagicMock()
|
migration_api = mock.MagicMock()
|
||||||
REPOSITORY = mock.MagicMock()
|
REPOSITORY = mock.MagicMock()
|
||||||
engine = mock.MagicMock()
|
engine = mock.MagicMock()
|
||||||
@ -185,7 +185,7 @@ class TestWalkVersions(test.BaseTestCase, migrate.WalkVersionsMixin):
|
|||||||
self.assertEqual(upgraded, self.migrate_up.call_args_list)
|
self.assertEqual(upgraded, self.migrate_up.call_args_list)
|
||||||
|
|
||||||
|
|
||||||
class ModelsMigrationSyncMixin(test_base._DbTestCase):
|
class ModelsMigrationSyncMixin(db_test_base._DbTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ModelsMigrationSyncMixin, self).setUp()
|
super(ModelsMigrationSyncMixin, self).setUp()
|
||||||
@ -367,7 +367,7 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase):
|
|||||||
class ModelsMigrationsSyncMySQL(
|
class ModelsMigrationsSyncMySQL(
|
||||||
ModelsMigrationSyncMixin,
|
ModelsMigrationSyncMixin,
|
||||||
migrate.ModelsMigrationsSync,
|
migrate.ModelsMigrationsSync,
|
||||||
test_base._MySQLOpportunisticTestCase,
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
):
|
):
|
||||||
|
|
||||||
def test_models_not_sync(self):
|
def test_models_not_sync(self):
|
||||||
@ -380,7 +380,7 @@ class ModelsMigrationsSyncMySQL(
|
|||||||
class ModelsMigrationsSyncPostgreSQL(
|
class ModelsMigrationsSyncPostgreSQL(
|
||||||
ModelsMigrationSyncMixin,
|
ModelsMigrationSyncMixin,
|
||||||
migrate.ModelsMigrationsSync,
|
migrate.ModelsMigrationsSync,
|
||||||
test_base._PostgreSQLOpportunisticTestCase,
|
db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
):
|
):
|
||||||
|
|
||||||
def test_models_not_sync(self):
|
def test_models_not_sync(self):
|
||||||
|
@ -17,20 +17,19 @@ from collections import abc
|
|||||||
import datetime
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from oslotest import base as oslo_test
|
|
||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy import Integer, String
|
from sqlalchemy import Integer, String
|
||||||
from sqlalchemy import event
|
from sqlalchemy import event
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
|
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
|
|
||||||
BASE = declarative_base()
|
BASE = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
class ModelBaseTest(test_base._DbTestCase):
|
class ModelBaseTest(db_test_base._DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(ModelBaseTest, self).setUp()
|
super(ModelBaseTest, self).setUp()
|
||||||
self.mb = models.ModelBase()
|
self.mb = models.ModelBase()
|
||||||
@ -174,7 +173,7 @@ class ExtraKeysModel(BASE, models.ModelBase):
|
|||||||
return ['name']
|
return ['name']
|
||||||
|
|
||||||
|
|
||||||
class TimestampMixinTest(oslo_test.BaseTestCase):
|
class TimestampMixinTest(test_base.BaseTestCase):
|
||||||
|
|
||||||
def test_timestampmixin_attr(self):
|
def test_timestampmixin_attr(self):
|
||||||
methods = ('created_at',
|
methods = ('created_at',
|
||||||
@ -191,7 +190,7 @@ class SoftDeletedModel(BASE, models.ModelBase, models.SoftDeleteMixin):
|
|||||||
smth = Column('smth', String(255))
|
smth = Column('smth', String(255))
|
||||||
|
|
||||||
|
|
||||||
class SoftDeleteMixinTest(test_base._DbTestCase):
|
class SoftDeleteMixinTest(db_test_base._DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(SoftDeleteMixinTest, self).setUp()
|
super(SoftDeleteMixinTest, self).setUp()
|
||||||
|
|
||||||
|
@ -21,23 +21,19 @@ from oslo_db.sqlalchemy import enginefacade
|
|||||||
from oslo_db.sqlalchemy import engines
|
from oslo_db.sqlalchemy import engines
|
||||||
from oslo_db.sqlalchemy import ndb
|
from oslo_db.sqlalchemy import ndb
|
||||||
from oslo_db.sqlalchemy import test_fixtures
|
from oslo_db.sqlalchemy import test_fixtures
|
||||||
from oslo_db.sqlalchemy import utils
|
|
||||||
|
|
||||||
from oslo_db.sqlalchemy.types import String
|
from oslo_db.sqlalchemy.types import String
|
||||||
|
from oslo_db.sqlalchemy import utils
|
||||||
from oslotest import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
from sqlalchemy import Column
|
from sqlalchemy import Column
|
||||||
from sqlalchemy import Integer
|
|
||||||
from sqlalchemy import MetaData
|
|
||||||
from sqlalchemy import Table
|
|
||||||
from sqlalchemy import Text
|
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy import schema
|
|
||||||
|
|
||||||
from sqlalchemy.dialects.mysql import TEXT
|
from sqlalchemy.dialects.mysql import TEXT
|
||||||
from sqlalchemy.dialects.mysql import TINYTEXT
|
from sqlalchemy.dialects.mysql import TINYTEXT
|
||||||
|
from sqlalchemy import Integer
|
||||||
|
from sqlalchemy import MetaData
|
||||||
|
from sqlalchemy import schema
|
||||||
|
from sqlalchemy import Table
|
||||||
|
from sqlalchemy import Text
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -155,7 +151,8 @@ class NDBDatatypesDefaultTestCase(NDBMockTestBase):
|
|||||||
|
|
||||||
|
|
||||||
class NDBOpportunisticTestCase(
|
class NDBOpportunisticTestCase(
|
||||||
test_fixtures.OpportunisticDBTestMixin, test_base.BaseTestCase):
|
test_fixtures.OpportunisticDBTestMixin, test_base.BaseTestCase,
|
||||||
|
):
|
||||||
|
|
||||||
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
FIXTURE = test_fixtures.MySQLOpportunisticFixture
|
||||||
|
|
||||||
|
@ -15,12 +15,13 @@ from oslo_config import cfg
|
|||||||
from oslo_config import fixture as config_fixture
|
from oslo_config import fixture as config_fixture
|
||||||
|
|
||||||
from oslo_db import options
|
from oslo_db import options
|
||||||
from oslo_db.tests import utils as test_utils
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
|
|
||||||
class DbApiOptionsTestCase(test_utils.BaseTestCase):
|
class DbApiOptionsTestCase(test_base.BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DbApiOptionsTestCase, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.conf = self.useFixture(config_fixture.Config()).conf
|
self.conf = self.useFixture(config_fixture.Config()).conf
|
||||||
self.conf.register_opts(options.database_opts, group='database')
|
self.conf.register_opts(options.database_opts, group='database')
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
import os
|
import os
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from oslotest import base as oslo_test_base
|
|
||||||
from sqlalchemy import exc as sa_exc
|
from sqlalchemy import exc as sa_exc
|
||||||
from sqlalchemy import inspect
|
from sqlalchemy import inspect
|
||||||
from sqlalchemy import schema
|
from sqlalchemy import schema
|
||||||
@ -24,10 +23,11 @@ from oslo_db.sqlalchemy import enginefacade
|
|||||||
from oslo_db.sqlalchemy import provision
|
from oslo_db.sqlalchemy import provision
|
||||||
from oslo_db.sqlalchemy import test_fixtures
|
from oslo_db.sqlalchemy import test_fixtures
|
||||||
from oslo_db.sqlalchemy import utils
|
from oslo_db.sqlalchemy import utils
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
|
|
||||||
|
|
||||||
class DropAllObjectsTest(test_base._DbTestCase):
|
class DropAllObjectsTest(db_test_base._DbTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DropAllObjectsTest, self).setUp()
|
super(DropAllObjectsTest, self).setUp()
|
||||||
@ -81,7 +81,7 @@ class DropAllObjectsTest(test_base._DbTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class BackendNotAvailableTest(oslo_test_base.BaseTestCase):
|
class BackendNotAvailableTest(test_base.BaseTestCase):
|
||||||
def test_no_dbapi(self):
|
def test_no_dbapi(self):
|
||||||
backend = provision.Backend(
|
backend = provision.Backend(
|
||||||
"postgresql", "postgresql+nosuchdbapi://hostname/dsn")
|
"postgresql", "postgresql+nosuchdbapi://hostname/dsn")
|
||||||
@ -138,16 +138,18 @@ class BackendNotAvailableTest(oslo_test_base.BaseTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class MySQLDropAllObjectsTest(
|
class MySQLDropAllObjectsTest(
|
||||||
DropAllObjectsTest, test_base._MySQLOpportunisticTestCase):
|
DropAllObjectsTest, db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PostgreSQLDropAllObjectsTest(
|
class PostgreSQLDropAllObjectsTest(
|
||||||
DropAllObjectsTest, test_base._PostgreSQLOpportunisticTestCase):
|
DropAllObjectsTest, db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class RetainSchemaTest(oslo_test_base.BaseTestCase):
|
class RetainSchemaTest(test_base.BaseTestCase):
|
||||||
DRIVER = "sqlite"
|
DRIVER = "sqlite"
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -222,7 +224,7 @@ class PostgresqlRetainSchemaTest(RetainSchemaTest):
|
|||||||
DRIVER = "postgresql"
|
DRIVER = "postgresql"
|
||||||
|
|
||||||
|
|
||||||
class AdHocURLTest(oslo_test_base.BaseTestCase):
|
class AdHocURLTest(test_base.BaseTestCase):
|
||||||
def test_sqlite_setup_teardown(self):
|
def test_sqlite_setup_teardown(self):
|
||||||
|
|
||||||
fixture = test_fixtures.AdHocDbFixture("sqlite:///foo.db")
|
fixture = test_fixtures.AdHocDbFixture("sqlite:///foo.db")
|
||||||
|
@ -23,7 +23,6 @@ from unittest import mock
|
|||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslotest import base as oslo_test
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import Column, MetaData, Table
|
from sqlalchemy import Column, MetaData, Table
|
||||||
from sqlalchemy.engine import url
|
from sqlalchemy.engine import url
|
||||||
@ -36,7 +35,8 @@ from oslo_db.sqlalchemy import enginefacade
|
|||||||
from oslo_db.sqlalchemy import engines
|
from oslo_db.sqlalchemy import engines
|
||||||
from oslo_db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo_db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
|
|
||||||
|
|
||||||
BASE = declarative_base()
|
BASE = declarative_base()
|
||||||
@ -51,7 +51,7 @@ class RegexpTable(BASE, models.ModelBase):
|
|||||||
bar = Column(String(255))
|
bar = Column(String(255))
|
||||||
|
|
||||||
|
|
||||||
class RegexpFilterTestCase(test_base._DbTestCase):
|
class RegexpFilterTestCase(db_test_base._DbTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(RegexpFilterTestCase, self).setUp()
|
super(RegexpFilterTestCase, self).setUp()
|
||||||
@ -65,8 +65,8 @@ class RegexpFilterTestCase(test_base._DbTestCase):
|
|||||||
self.addCleanup(test_table.drop)
|
self.addCleanup(test_table.drop)
|
||||||
|
|
||||||
def _test_regexp_filter(self, regexp, expected):
|
def _test_regexp_filter(self, regexp, expected):
|
||||||
with enginefacade.writer.using(test_base.context):
|
with enginefacade.writer.using(db_test_base.context):
|
||||||
_session = test_base.context.session
|
_session = db_test_base.context.session
|
||||||
for i in ['10', '20', '♥']:
|
for i in ['10', '20', '♥']:
|
||||||
tbl = RegexpTable()
|
tbl = RegexpTable()
|
||||||
tbl.update({'bar': i})
|
tbl.update({'bar': i})
|
||||||
@ -89,7 +89,7 @@ class RegexpFilterTestCase(test_base._DbTestCase):
|
|||||||
self._test_regexp_filter('♦', [])
|
self._test_regexp_filter('♦', [])
|
||||||
|
|
||||||
|
|
||||||
class SQLiteSavepointTest(test_base._DbTestCase):
|
class SQLiteSavepointTest(db_test_base._DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(SQLiteSavepointTest, self).setUp()
|
super(SQLiteSavepointTest, self).setUp()
|
||||||
meta = MetaData()
|
meta = MetaData()
|
||||||
@ -202,7 +202,7 @@ class ProgrammingError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class QueryParamTest(test_base.DbTestCase):
|
class QueryParamTest(db_test_base.DbTestCase):
|
||||||
def _fixture(self):
|
def _fixture(self):
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ class QueryParamTest(test_base.DbTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MySQLDefaultModeTestCase(test_base._MySQLOpportunisticTestCase):
|
class MySQLDefaultModeTestCase(db_test_base._MySQLOpportunisticTestCase):
|
||||||
def test_default_is_traditional(self):
|
def test_default_is_traditional(self):
|
||||||
with self.engine.connect() as conn:
|
with self.engine.connect() as conn:
|
||||||
sql_mode = conn.execute(
|
sql_mode = conn.execute(
|
||||||
@ -295,7 +295,7 @@ class MySQLDefaultModeTestCase(test_base._MySQLOpportunisticTestCase):
|
|||||||
self.assertIn("TRADITIONAL", sql_mode)
|
self.assertIn("TRADITIONAL", sql_mode)
|
||||||
|
|
||||||
|
|
||||||
class MySQLModeTestCase(test_base._MySQLOpportunisticTestCase):
|
class MySQLModeTestCase(db_test_base._MySQLOpportunisticTestCase):
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(MySQLModeTestCase, self).__init__(*args, **kwargs)
|
super(MySQLModeTestCase, self).__init__(*args, **kwargs)
|
||||||
@ -364,7 +364,7 @@ class MySQLTraditionalModeTestCase(MySQLStrictAllTablesModeTestCase):
|
|||||||
self.mysql_mode = 'TRADITIONAL'
|
self.mysql_mode = 'TRADITIONAL'
|
||||||
|
|
||||||
|
|
||||||
class EngineFacadeTestCase(oslo_test.BaseTestCase):
|
class EngineFacadeTestCase(test_base.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(EngineFacadeTestCase, self).setUp()
|
super(EngineFacadeTestCase, self).setUp()
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ class EngineFacadeTestCase(oslo_test.BaseTestCase):
|
|||||||
self.assertEqual(master_path, str(slave_session.bind.url))
|
self.assertEqual(master_path, str(slave_session.bind.url))
|
||||||
|
|
||||||
|
|
||||||
class SQLiteConnectTest(oslo_test.BaseTestCase):
|
class SQLiteConnectTest(test_base.BaseTestCase):
|
||||||
|
|
||||||
def _fixture(self, **kw):
|
def _fixture(self, **kw):
|
||||||
return session.create_engine("sqlite://", **kw)
|
return session.create_engine("sqlite://", **kw)
|
||||||
@ -507,7 +507,7 @@ class SQLiteConnectTest(oslo_test.BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class MysqlConnectTest(test_base._MySQLOpportunisticTestCase):
|
class MysqlConnectTest(db_test_base._MySQLOpportunisticTestCase):
|
||||||
|
|
||||||
def _fixture(self, sql_mode):
|
def _fixture(self, sql_mode):
|
||||||
return session.create_engine(self.engine.url, mysql_sql_mode=sql_mode)
|
return session.create_engine(self.engine.url, mysql_sql_mode=sql_mode)
|
||||||
@ -627,7 +627,7 @@ class MysqlConnectTest(test_base._MySQLOpportunisticTestCase):
|
|||||||
log.output)
|
log.output)
|
||||||
|
|
||||||
|
|
||||||
class CreateEngineTest(oslo_test.BaseTestCase):
|
class CreateEngineTest(test_base.BaseTestCase):
|
||||||
"""Test that dialect-specific arguments/ listeners are set up correctly.
|
"""Test that dialect-specific arguments/ listeners are set up correctly.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -781,7 +781,7 @@ class CreateEngineTest(oslo_test.BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ProcessGuardTest(test_base._DbTestCase):
|
class ProcessGuardTest(db_test_base._DbTestCase):
|
||||||
def test_process_guard(self):
|
def test_process_guard(self):
|
||||||
self.engine.dispose()
|
self.engine.dispose()
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ class ProcessGuardTest(test_base._DbTestCase):
|
|||||||
self.assertEqual(new_dbapi_id, newer_dbapi_id)
|
self.assertEqual(new_dbapi_id, newer_dbapi_id)
|
||||||
|
|
||||||
|
|
||||||
class PatchStacktraceTest(test_base._DbTestCase):
|
class PatchStacktraceTest(db_test_base._DbTestCase):
|
||||||
|
|
||||||
def test_trace(self):
|
def test_trace(self):
|
||||||
engine = self.engine
|
engine = self.engine
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
from oslotest import base as oslo_test_base
|
|
||||||
from sqlalchemy.ext import declarative
|
from sqlalchemy.ext import declarative
|
||||||
from sqlalchemy import schema
|
from sqlalchemy import schema
|
||||||
from sqlalchemy import sql
|
from sqlalchemy import sql
|
||||||
from sqlalchemy import types as sqltypes
|
from sqlalchemy import types as sqltypes
|
||||||
|
|
||||||
from oslo_db.sqlalchemy import update_match
|
from oslo_db.sqlalchemy import update_match
|
||||||
from oslo_db.tests.sqlalchemy import base as test_base
|
from oslo_db.tests import base as test_base
|
||||||
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
|
|
||||||
Base = declarative.declarative_base()
|
Base = declarative.declarative_base()
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class MyModel(Base):
|
|||||||
z = schema.Column(sqltypes.String(40))
|
z = schema.Column(sqltypes.String(40))
|
||||||
|
|
||||||
|
|
||||||
class ManufactureCriteriaTest(oslo_test_base.BaseTestCase):
|
class ManufactureCriteriaTest(test_base.BaseTestCase):
|
||||||
def test_instance_criteria_basic(self):
|
def test_instance_criteria_basic(self):
|
||||||
specimen = MyModel(
|
specimen = MyModel(
|
||||||
y='y1', z='z3',
|
y='y1', z='z3',
|
||||||
@ -85,7 +85,7 @@ class ManufactureCriteriaTest(oslo_test_base.BaseTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class UpdateMatchTest(test_base._DbTestCase):
|
class UpdateMatchTest(db_test_base._DbTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(UpdateMatchTest, self).setUp()
|
super(UpdateMatchTest, self).setUp()
|
||||||
Base.metadata.create_all(self.engine)
|
Base.metadata.create_all(self.engine)
|
||||||
@ -434,12 +434,14 @@ class UpdateMatchTest(test_base._DbTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class PGUpdateMatchTest(
|
class PGUpdateMatchTest(
|
||||||
UpdateMatchTest,
|
UpdateMatchTest,
|
||||||
test_base._PostgreSQLOpportunisticTestCase):
|
db_test_base._PostgreSQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MySQLUpdateMatchTest(
|
class MySQLUpdateMatchTest(
|
||||||
UpdateMatchTest,
|
UpdateMatchTest,
|
||||||
test_base._MySQLOpportunisticTestCase):
|
db_test_base._MySQLOpportunisticTestCase,
|
||||||
|
):
|
||||||
pass
|
pass
|
||||||
|
@ -17,7 +17,6 @@ from unittest import mock
|
|||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslotest import base as test_base
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy.dialects import mysql
|
from sqlalchemy.dialects import mysql
|
||||||
from sqlalchemy import Boolean, Index, Integer, DateTime, String
|
from sqlalchemy import Boolean, Index, Integer, DateTime, String
|
||||||
@ -42,9 +41,8 @@ from oslo_db.sqlalchemy import models
|
|||||||
from oslo_db.sqlalchemy import provision
|
from oslo_db.sqlalchemy import provision
|
||||||
from oslo_db.sqlalchemy import session
|
from oslo_db.sqlalchemy import session
|
||||||
from oslo_db.sqlalchemy import utils
|
from oslo_db.sqlalchemy import utils
|
||||||
|
from oslo_db.tests import base as test_base
|
||||||
from oslo_db.tests.sqlalchemy import base as db_test_base
|
from oslo_db.tests.sqlalchemy import base as db_test_base
|
||||||
from oslo_db.tests import utils as test_utils
|
|
||||||
|
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
@ -1073,7 +1071,7 @@ class MySQLTestMigrations(TestMigrationUtils,
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TestConnectionUtils(test_utils.BaseTestCase):
|
class TestConnectionUtils(test_base.BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestConnectionUtils, self).setUp()
|
super(TestConnectionUtils, self).setUp()
|
||||||
|
@ -22,7 +22,7 @@ from oslo_utils import importutils
|
|||||||
|
|
||||||
from oslo_db import api
|
from oslo_db import api
|
||||||
from oslo_db import exception
|
from oslo_db import exception
|
||||||
from oslo_db.tests import utils as test_utils
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
sqla = importutils.try_import('sqlalchemy')
|
sqla = importutils.try_import('sqlalchemy')
|
||||||
if not sqla:
|
if not sqla:
|
||||||
@ -65,7 +65,8 @@ class DBAPI(object):
|
|||||||
return args, kwargs
|
return args, kwargs
|
||||||
|
|
||||||
|
|
||||||
class DBAPITestCase(test_utils.BaseTestCase):
|
class DBAPITestCase(test_base.BaseTestCase):
|
||||||
|
|
||||||
def test_dbapi_full_path_module_method(self):
|
def test_dbapi_full_path_module_method(self):
|
||||||
dbapi = api.DBAPI('oslo_db.tests.test_api')
|
dbapi = api.DBAPI('oslo_db.tests.test_api')
|
||||||
result = dbapi.api_class_call1(1, 2, kwarg1='meow')
|
result = dbapi.api_class_call1(1, 2, kwarg1='meow')
|
||||||
@ -91,8 +92,9 @@ class DBAPITestCase(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class DBReconnectTestCase(DBAPITestCase):
|
class DBReconnectTestCase(DBAPITestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(DBReconnectTestCase, self).setUp()
|
super().setUp()
|
||||||
|
|
||||||
self.test_db_api = DBAPI()
|
self.test_db_api = DBAPI()
|
||||||
patcher = mock.patch(__name__ + '.get_backend',
|
patcher = mock.patch(__name__ + '.get_backend',
|
||||||
@ -200,6 +202,7 @@ class DBReconnectTestCase(DBAPITestCase):
|
|||||||
|
|
||||||
|
|
||||||
class DBRetryRequestCase(DBAPITestCase):
|
class DBRetryRequestCase(DBAPITestCase):
|
||||||
|
|
||||||
def test_retry_wrapper_succeeds(self):
|
def test_retry_wrapper_succeeds(self):
|
||||||
@api.wrap_db_retry(max_retries=10)
|
@api.wrap_db_retry(max_retries=10)
|
||||||
def some_method():
|
def some_method():
|
||||||
@ -294,6 +297,7 @@ class DBRetryRequestCase(DBAPITestCase):
|
|||||||
x = api.wrap_db_retry(max_retries=5, retry_on_deadlock=True,
|
x = api.wrap_db_retry(max_retries=5, retry_on_deadlock=True,
|
||||||
max_retry_interval=11)
|
max_retry_interval=11)
|
||||||
self.assertEqual(11, x.max_retry_interval)
|
self.assertEqual(11, x.max_retry_interval)
|
||||||
|
|
||||||
for i in (1, 2, 4):
|
for i in (1, 2, 4):
|
||||||
# With jitter: sleep_time = [0, 2 ** retry_times)
|
# With jitter: sleep_time = [0, 2 ** retry_times)
|
||||||
sleep_time, n = x._get_inc_interval(i, True)
|
sleep_time, n = x._get_inc_interval(i, True)
|
||||||
@ -303,6 +307,7 @@ class DBRetryRequestCase(DBAPITestCase):
|
|||||||
sleep_time, n = x._get_inc_interval(i, False)
|
sleep_time, n = x._get_inc_interval(i, False)
|
||||||
self.assertEqual(2 * i, n)
|
self.assertEqual(2 * i, n)
|
||||||
self.assertEqual(2 * i, sleep_time)
|
self.assertEqual(2 * i, sleep_time)
|
||||||
|
|
||||||
for i in (8, 16, 32):
|
for i in (8, 16, 32):
|
||||||
sleep_time, n = x._get_inc_interval(i, False)
|
sleep_time, n = x._get_inc_interval(i, False)
|
||||||
self.assertEqual(x.max_retry_interval, sleep_time)
|
self.assertEqual(x.max_retry_interval, sleep_time)
|
||||||
|
@ -19,12 +19,12 @@ from unittest import mock
|
|||||||
from oslo_config import fixture as config_fixture
|
from oslo_config import fixture as config_fixture
|
||||||
|
|
||||||
from oslo_db import concurrency
|
from oslo_db import concurrency
|
||||||
from oslo_db.tests import utils as test_utils
|
from oslo_db.tests import base as test_base
|
||||||
|
|
||||||
FAKE_BACKEND_MAPPING = {'sqlalchemy': 'fake.db.sqlalchemy.api'}
|
FAKE_BACKEND_MAPPING = {'sqlalchemy': 'fake.db.sqlalchemy.api'}
|
||||||
|
|
||||||
|
|
||||||
class TpoolDbapiWrapperTestCase(test_utils.BaseTestCase):
|
class TpoolDbapiWrapperTestCase(test_base.BaseTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TpoolDbapiWrapperTestCase, self).setUp()
|
super(TpoolDbapiWrapperTestCase, self).setUp()
|
||||||
|
@ -15,15 +15,8 @@
|
|||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
from oslotest import base as test_base
|
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def nested(*contexts):
|
def nested(*contexts):
|
||||||
with contextlib.ExitStack() as stack:
|
with contextlib.ExitStack() as stack:
|
||||||
yield [stack.enter_context(c) for c in contexts]
|
yield [stack.enter_context(c) for c in contexts]
|
||||||
|
|
||||||
|
|
||||||
# TODO(stephenfin): Remove as this is no longer necessary
|
|
||||||
class BaseTestCase(test_base.BaseTestCase):
|
|
||||||
pass
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user