From 2382f46d4e209abd271fd32f45a9e8f95ad07231 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Thu, 19 Oct 2017 17:44:33 -0400 Subject: [PATCH] Unit tests: Remove deprecated oslo_db test case classes Migrate to the new, modern, fixtures-based test framework in oslo_db. This eliminates about 35 deprecation messages when running the unit tests. Change-Id: I502c8f9e0718558ae93ff5a568c1ef9ee17ca7f7 --- heat/tests/db/test_migrations.py | 56 ++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/heat/tests/db/test_migrations.py b/heat/tests/db/test_migrations.py index e61fa3341f..62670531fd 100644 --- a/heat/tests/db/test_migrations.py +++ b/heat/tests/db/test_migrations.py @@ -26,11 +26,13 @@ import os import uuid from migrate.versioning import repository -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 from oslo_serialization import jsonutils from oslo_utils import timeutils +from oslotest import base as test_base import six import sqlalchemy import testtools @@ -738,18 +740,24 @@ class HeatMigrationsCheckers(test_migrations.WalkVersionsMixin, 'attr_data_id') -class TestHeatMigrationsMySQL(HeatMigrationsCheckers, - test_base.MySQLOpportunisticTestCase): - pass +class DbTestCase(test_fixtures.OpportunisticDBTestMixin, + test_base.BaseTestCase): + def setUp(self): + super(DbTestCase, self).setUp() + + self.engine = enginefacade.writer.get_engine() + self.sessionmaker = enginefacade.writer.get_sessionmaker() -class TestHeatMigrationsPostgreSQL(HeatMigrationsCheckers, - test_base.PostgreSQLOpportunisticTestCase): - pass +class TestHeatMigrationsMySQL(DbTestCase, HeatMigrationsCheckers): + FIXTURE = test_fixtures.MySQLOpportunisticFixture -class TestHeatMigrationsSQLite(HeatMigrationsCheckers, - test_base.DbTestCase): +class TestHeatMigrationsPostgreSQL(DbTestCase, HeatMigrationsCheckers): + FIXTURE = test_fixtures.PostgresqlOpportunisticFixture + + +class TestHeatMigrationsSQLite(DbTestCase, HeatMigrationsCheckers): pass @@ -770,19 +778,19 @@ class ModelsMigrationSyncMixin(object): return True -class ModelsMigrationsSyncMysql(ModelsMigrationSyncMixin, - test_migrations.ModelsMigrationsSync, - test_base.MySQLOpportunisticTestCase): - pass - - -class ModelsMigrationsSyncPostgres(ModelsMigrationSyncMixin, - test_migrations.ModelsMigrationsSync, - test_base.PostgreSQLOpportunisticTestCase): - pass - - -class ModelsMigrationsSyncSQLite(ModelsMigrationSyncMixin, - test_migrations.ModelsMigrationsSync, - test_base.DbTestCase): +class ModelsMigrationsSyncMysql(DbTestCase, + ModelsMigrationSyncMixin, + test_migrations.ModelsMigrationsSync): + FIXTURE = test_fixtures.MySQLOpportunisticFixture + + +class ModelsMigrationsSyncPostgres(DbTestCase, + ModelsMigrationSyncMixin, + test_migrations.ModelsMigrationsSync): + FIXTURE = test_fixtures.PostgresqlOpportunisticFixture + + +class ModelsMigrationsSyncSQLite(DbTestCase, + ModelsMigrationSyncMixin, + test_migrations.ModelsMigrationsSync): pass