summaryrefslogtreecommitdiff
path: root/oslo_db/tests
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2023-02-17 12:54:24 +0000
committerTakashi Kajinami <tkajinam@redhat.com>2023-03-22 15:05:24 +0000
commita609333c5482228ee69baab91858e1812909cd55 (patch)
treeec8aeff9fff0d0a7041294c5d1728ac8bdfd0a5d /oslo_db/tests
parent94d6e24ca19b0116eed00d5ccdb8a538918c6dcf (diff)
downloadoslo-db-a609333c5482228ee69baab91858e1812909cd55.tar.gz
Remove legacy base test classes
The fixtures have been available for a very long time now. We can drop these. Change-Id: I1e71150ba6daeba464b6ed8d46163f1f34959db3 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'oslo_db/tests')
-rw-r--r--oslo_db/tests/sqlalchemy/base.py31
-rw-r--r--oslo_db/tests/sqlalchemy/test_fixtures.py97
-rw-r--r--oslo_db/tests/sqlalchemy/test_sqlalchemy.py2
3 files changed, 1 insertions, 129 deletions
diff --git a/oslo_db/tests/sqlalchemy/base.py b/oslo_db/tests/sqlalchemy/base.py
index 80d9812..c66618a 100644
--- a/oslo_db/tests/sqlalchemy/base.py
+++ b/oslo_db/tests/sqlalchemy/base.py
@@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import debtcollector
-
from oslo_db.sqlalchemy import enginefacade
from oslo_db.sqlalchemy.test_base import backend_specific # noqa
from oslo_db.sqlalchemy import test_fixtures as db_fixtures
@@ -29,35 +27,6 @@ class Context(object):
context = Context()
-@debtcollector.removals.removed_class(
- "DbTestCase",
- message="Do not import from oslo_db.tests! "
- "Please use oslo_db.sqlalchemy.test_fixtures directly")
-class DbTestCase(db_fixtures.OpportunisticDBTestMixin, test_base.BaseTestCase):
-
- def setUp(self):
- super(DbTestCase, self).setUp()
-
- self.engine = enginefacade.writer.get_engine()
- self.sessionmaker = enginefacade.writer.get_sessionmaker()
-
-
-@debtcollector.removals.removed_class(
- "MySQLOpportunisticTestCase",
- message="Do not import from oslo_db.tests! "
- "Please use oslo_db.sqlalchemy.test_fixtures directly")
-class MySQLOpportunisticTestCase(DbTestCase):
- FIXTURE = db_fixtures.MySQLOpportunisticFixture
-
-
-@debtcollector.removals.removed_class(
- "PostgreSQLOpportunisticTestCase",
- message="Do not import from oslo_db.tests! "
- "Please use oslo_db.sqlalchemy.test_fixtures directly")
-class PostgreSQLOpportunisticTestCase(DbTestCase):
- FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
-
-
# NOTE (zzzeek) These test classes are **private to oslo.db**. Please
# make use of oslo_db.sqlalchemy.test_fixtures directly.
diff --git a/oslo_db/tests/sqlalchemy/test_fixtures.py b/oslo_db/tests/sqlalchemy/test_fixtures.py
index 72f4f93..eff5c7e 100644
--- a/oslo_db/tests/sqlalchemy/test_fixtures.py
+++ b/oslo_db/tests/sqlalchemy/test_fixtures.py
@@ -16,10 +16,8 @@ import testscenarios
import unittest
from unittest import mock
-from oslo_db import exception
from oslo_db.sqlalchemy import enginefacade
from oslo_db.sqlalchemy import provision
-from oslo_db.sqlalchemy import test_base as legacy_test_base
from oslo_db.sqlalchemy import test_fixtures
from oslo_db.tests import base as test_base
@@ -96,74 +94,6 @@ class BackendSkipTest(test_base.BaseTestCase):
str(ex)
)
- def test_skip_no_dbapi_legacy(self):
-
- class FakeDatabaseOpportunisticFixture(
- legacy_test_base.DbFixture,
- ):
- DRIVER = 'postgresql'
-
- class SomeTest(legacy_test_base.DbTestCase):
- FIXTURE = FakeDatabaseOpportunisticFixture
-
- def runTest(self):
- pass
-
- st = SomeTest()
-
- # patch in replacement lookup dictionaries to avoid
- # leaking from/to other tests
- with mock.patch(
- "oslo_db.sqlalchemy.provision."
- "Backend.backends_by_database_type", {
- "postgresql":
- provision.Backend("postgresql", "postgresql://")}):
- st._database_resources = {}
- st._db_not_available = {}
- st._schema_resources = {}
-
- with mock.patch(
- "sqlalchemy.create_engine",
- mock.Mock(side_effect=ImportError())):
-
- self.assertEqual([], st.resources)
-
- ex = self.assertRaises(
- self.skipException,
- st.setUp
- )
-
- self.assertEqual(
- "Backend 'postgresql' is unavailable: No DBAPI installed",
- str(ex)
- )
-
- def test_skip_no_such_backend_legacy(self):
-
- class FakeDatabaseOpportunisticFixture(
- legacy_test_base.DbFixture,
- ):
- DRIVER = 'postgresql+nosuchdbapi'
-
- class SomeTest(legacy_test_base.DbTestCase):
-
- FIXTURE = FakeDatabaseOpportunisticFixture
-
- def runTest(self):
- pass
-
- st = SomeTest()
-
- ex = self.assertRaises(
- self.skipException,
- st.setUp
- )
-
- self.assertEqual(
- "Backend 'postgresql+nosuchdbapi' is unavailable: No such backend",
- str(ex)
- )
-
class EnginefacadeIntegrationTest(test_base.BaseTestCase):
def test_db_fixture(self):
@@ -206,33 +136,6 @@ class EnginefacadeIntegrationTest(test_base.BaseTestCase):
self.assertFalse(normal_mgr._factory._started)
-class LegacyBaseClassTest(test_base.BaseTestCase):
- def test_new_db_is_provisioned_by_default_pg(self):
- self._test_new_db_is_provisioned_by_default(
- legacy_test_base.PostgreSQLOpportunisticTestCase
- )
-
- def test_new_db_is_provisioned_by_default_mysql(self):
- self._test_new_db_is_provisioned_by_default(
- legacy_test_base.MySQLOpportunisticTestCase
- )
-
- def _test_new_db_is_provisioned_by_default(self, base_cls):
- try:
- provision.DatabaseResource(base_cls.FIXTURE.DRIVER)
- except exception.BackendNotAvailable:
- self.skipTest("Backend %s is not available" %
- base_cls.FIXTURE.DRIVER)
-
- class SomeTest(base_cls):
- def runTest(self):
- pass
- st = SomeTest()
-
- db_resource = dict(st.resources)['db']
- self.assertTrue(db_resource.provision_new_database)
-
-
class TestLoadHook(unittest.TestCase):
"""Test the 'load_tests' hook supplied by test_base.
diff --git a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
index ec75ffc..8488edf 100644
--- a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
+++ b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
@@ -205,7 +205,7 @@ class ProgrammingError(Exception):
pass
-class QueryParamTest(db_test_base.DbTestCase):
+class QueryParamTest(db_test_base._DbTestCase):
def _fixture(self):
from sqlalchemy import create_engine