diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-11-29 17:28:18 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-11-29 17:28:18 -0500 |
commit | c8c635e18d65fd31cf28617185a70627092e8ab7 (patch) | |
tree | 2d19200fbafeb89c87bb5de3ff3479c612d8a347 /oslo_db | |
parent | 5b68df20fb3a0450124c22d848b468cefc8d2c29 (diff) | |
download | oslo-db-c8c635e18d65fd31cf28617185a70627092e8ab7.tar.gz |
Don't run LegacyBaseClass provision test for unavailable database
The test added in I3e238b6a97769cf0a352f11e718d5d73eebcfa8a
will fail if the corresponding backend is not actually
available, because the resources dictionary will be empty.
Add a skip mechanism based on whether or not the DatabaseResource
has backend available or not.
Change-Id: I0ecb4a7ba6531b50c9c3abc6c9c8564b0df54f61
Diffstat (limited to 'oslo_db')
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_fixtures.py | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/oslo_db/tests/sqlalchemy/test_fixtures.py b/oslo_db/tests/sqlalchemy/test_fixtures.py index f256d30..b769e20 100644 --- a/oslo_db/tests/sqlalchemy/test_fixtures.py +++ b/oslo_db/tests/sqlalchemy/test_fixtures.py @@ -16,6 +16,7 @@ import testresources import testscenarios import unittest +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 @@ -204,19 +205,30 @@ class EnginefacadeIntegrationTest(oslo_test_base.BaseTestCase): class LegacyBaseClassTest(oslo_test_base.BaseTestCase): - def test_new_db_is_provisioned_by_default(self): - classes = [ - legacy_test_base.MySQLOpportunisticTestCase, + def test_new_db_is_provisioned_by_default_pg(self): + self._test_new_db_is_provisioned_by_default( legacy_test_base.PostgreSQLOpportunisticTestCase - ] - for base_cls in classes: - class SomeTest(base_cls): - def runTest(self): - pass - st = SomeTest() - - db_resource = dict(st.resources)['db'] - self.assertTrue(db_resource.provision_new_database) + ) + + 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.skip("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): |