@@ -5652,7 +5652,7 @@ class ArchiveTestCase(test.TestCase, ModelsObjectComparatorMixin):
5652
5652
def setUp (self ):
5653
5653
super (ArchiveTestCase , self ).setUp ()
5654
5654
self .engine = db .get_engine ()
5655
- self .metadata = sa .MetaData (self . engine )
5655
+ self .metadata = sa .MetaData ()
5656
5656
self .conn = self .engine .connect ()
5657
5657
self .instance_id_mappings = models .InstanceIdMapping .__table__
5658
5658
self .shadow_instance_id_mappings = sqlalchemyutils .get_table (
@@ -5684,8 +5684,8 @@ def _assert_shadow_tables_empty_except(self, *exceptions):
5684
5684
except for specificially named exceptions, are empty. This
5685
5685
makes sure that archiving isn't moving unexpected content.
5686
5686
"""
5687
- metadata = sa .MetaData (bind = self . engine )
5688
- metadata .reflect ()
5687
+ metadata = sa .MetaData ()
5688
+ metadata .reflect (bind = self . engine )
5689
5689
for table in metadata .tables :
5690
5690
if table .startswith ("shadow_" ) and table not in exceptions :
5691
5691
rows = self .conn .exec_driver_sql (
@@ -5698,8 +5698,8 @@ def test_shadow_tables(self):
5698
5698
5699
5699
Shadow tables should have an identical schema to the main table.
5700
5700
"""
5701
- metadata = sa .MetaData (bind = self . engine )
5702
- metadata .reflect ()
5701
+ metadata = sa .MetaData ()
5702
+ metadata .reflect (bind = self . engine )
5703
5703
for table_name in metadata .tables :
5704
5704
# some tables don't have shadow tables so skip these
5705
5705
if table_name in [
@@ -5942,7 +5942,9 @@ def _test_archive_deleted_rows_for_one_uuid_table(self, tablename):
5942
5942
self .assertEqual (len (rows ), 0 )
5943
5943
# Archive 2 rows
5944
5944
db ._archive_deleted_rows_for_table (
5945
- self .metadata , tablename , max_rows = 2 , before = None , task_log = False )
5945
+ self .metadata , self .engine , tablename , max_rows = 2 , before = None ,
5946
+ task_log = False ,
5947
+ )
5946
5948
# Verify we have 4 left in main
5947
5949
rows = self .conn .execute (qmt ).fetchall ()
5948
5950
self .assertEqual (len (rows ), 4 )
@@ -5951,7 +5953,9 @@ def _test_archive_deleted_rows_for_one_uuid_table(self, tablename):
5951
5953
self .assertEqual (len (rows ), 2 )
5952
5954
# Archive 2 more rows
5953
5955
db ._archive_deleted_rows_for_table (
5954
- self .metadata , tablename , max_rows = 2 , before = None , task_log = False )
5956
+ self .metadata , self .engine , tablename , max_rows = 2 , before = None ,
5957
+ task_log = False ,
5958
+ )
5955
5959
# Verify we have 2 left in main
5956
5960
rows = self .conn .execute (qmt ).fetchall ()
5957
5961
self .assertEqual (len (rows ), 2 )
@@ -5960,7 +5964,9 @@ def _test_archive_deleted_rows_for_one_uuid_table(self, tablename):
5960
5964
self .assertEqual (len (rows ), 4 )
5961
5965
# Try to archive more, but there are no deleted rows left.
5962
5966
db ._archive_deleted_rows_for_table (
5963
- self .metadata , tablename , max_rows = 2 , before = None , task_log = False )
5967
+ self .metadata , self .engine , tablename , max_rows = 2 , before = None ,
5968
+ task_log = False ,
5969
+ )
5964
5970
# Verify we still have 2 left in main
5965
5971
rows = self .conn .execute (qmt ).fetchall ()
5966
5972
self .assertEqual (len (rows ), 2 )
@@ -6019,8 +6025,8 @@ def test_archive_deleted_rows_for_migrations(self):
6019
6025
# Archiving instances should result in migrations related to the
6020
6026
# instances also being archived.
6021
6027
num = db ._archive_deleted_rows_for_table (
6022
- self .metadata , "instances" , max_rows = None , before = None ,
6023
- task_log = False )
6028
+ self .metadata , self . engine , "instances" , max_rows = None ,
6029
+ before = None , task_log = False )
6024
6030
self .assertEqual (1 , num [0 ])
6025
6031
self ._assert_shadow_tables_empty_except (
6026
6032
'shadow_instances' ,
@@ -6386,7 +6392,8 @@ def call_api(*args, **kwargs):
6386
6392
6387
6393
6388
6394
class TestSqlalchemyTypesRepr (
6389
- test_fixtures .OpportunisticDBTestMixin , test .NoDBTestCase ):
6395
+ test_fixtures .OpportunisticDBTestMixin , test .NoDBTestCase ,
6396
+ ):
6390
6397
6391
6398
def setUp (self ):
6392
6399
# NOTE(sdague): the oslo_db base test case completely
@@ -6397,15 +6404,15 @@ def setUp(self):
6397
6404
6398
6405
super (TestSqlalchemyTypesRepr , self ).setUp ()
6399
6406
self .engine = enginefacade .writer .get_engine ()
6400
- meta = sa .MetaData (bind = self . engine )
6407
+ meta = sa .MetaData ()
6401
6408
self .table = sa .Table (
6402
6409
'cidr_tbl' ,
6403
6410
meta ,
6404
6411
sa .Column ('id' , sa .Integer , primary_key = True ),
6405
6412
sa .Column ('addr' , col_types .CIDR ())
6406
6413
)
6407
- self . table . create ( )
6408
- self .addCleanup (meta .drop_all )
6414
+ meta . create_all ( self . engine )
6415
+ self .addCleanup (meta .drop_all , self . engine )
6409
6416
6410
6417
def test_cidr_repr (self ):
6411
6418
addrs = [('192.168.3.0/24' , '192.168.3.0/24' ),
0 commit comments