db: Replace dict-style access of Row attributes
Resolve the following RemovedIn20Warning: Using non-integer/slice indices on Row is deprecated and will be removed in version 2.0; please use row._mapping[<key>], or the mappings() accessor on the Result object. Change-Id: Ife8bdf766eb6d6fe9748565c9c61aa971d1af6f8 Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
25dcacea7c
commit
ce5056ad3a
@ -72,13 +72,13 @@ class TestOcataExpand01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
self.assertEqual(2, len(rows))
|
||||
# private image first
|
||||
self.assertEqual(0, rows[0]['is_public'])
|
||||
self.assertEqual('private_id_before_expand', rows[0]['id'])
|
||||
self.assertIsNone(rows[0]['visibility'])
|
||||
self.assertEqual(0, rows[0].is_public)
|
||||
self.assertEqual('private_id_before_expand', rows[0].id)
|
||||
self.assertIsNone(rows[0].visibility)
|
||||
# then public image
|
||||
self.assertEqual(1, rows[1]['is_public'])
|
||||
self.assertEqual('public_id_before_expand', rows[1]['id'])
|
||||
self.assertIsNone(rows[1]['visibility'])
|
||||
self.assertEqual(1, rows[1].is_public)
|
||||
self.assertEqual('public_id_before_expand', rows[1].id)
|
||||
self.assertIsNone(rows[1].visibility)
|
||||
|
||||
self._test_trigger_old_to_new(engine, images)
|
||||
self._test_trigger_new_to_old(engine, images)
|
||||
@ -129,17 +129,17 @@ class TestOcataExpand01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
self.assertEqual(3, len(rows))
|
||||
# private image first
|
||||
self.assertEqual(0, rows[0]['is_public'])
|
||||
self.assertEqual('private_id_new_to_old', rows[0]['id'])
|
||||
self.assertEqual('private', rows[0]['visibility'])
|
||||
self.assertEqual(0, rows[0].is_public)
|
||||
self.assertEqual('private_id_new_to_old', rows[0].id)
|
||||
self.assertEqual('private', rows[0].visibility)
|
||||
# then public image
|
||||
self.assertEqual(1, rows[1]['is_public'])
|
||||
self.assertEqual('public_id_new_to_old', rows[1]['id'])
|
||||
self.assertEqual('public', rows[1]['visibility'])
|
||||
self.assertEqual(1, rows[1].is_public)
|
||||
self.assertEqual('public_id_new_to_old', rows[1].id)
|
||||
self.assertEqual('public', rows[1].visibility)
|
||||
# then shared image
|
||||
self.assertEqual(0, rows[2]['is_public'])
|
||||
self.assertEqual('shared_id_new_to_old', rows[2]['id'])
|
||||
self.assertEqual('shared', rows[2]['visibility'])
|
||||
self.assertEqual(0, rows[2].is_public)
|
||||
self.assertEqual('shared_id_new_to_old', rows[2].id)
|
||||
self.assertEqual('shared', rows[2].visibility)
|
||||
|
||||
def _test_trigger_old_to_new(self, engine, images):
|
||||
now = datetime.datetime.now()
|
||||
@ -176,13 +176,13 @@ class TestOcataExpand01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
self.assertEqual(2, len(rows))
|
||||
# private image first
|
||||
self.assertEqual(0, rows[0]['is_public'])
|
||||
self.assertEqual('private_id_old_to_new', rows[0]['id'])
|
||||
self.assertEqual('shared', rows[0]['visibility'])
|
||||
self.assertEqual(0, rows[0].is_public)
|
||||
self.assertEqual('private_id_old_to_new', rows[0].id)
|
||||
self.assertEqual('shared', rows[0].visibility)
|
||||
# then public image
|
||||
self.assertEqual(1, rows[1]['is_public'])
|
||||
self.assertEqual('public_id_old_to_new', rows[1]['id'])
|
||||
self.assertEqual('public', rows[1]['visibility'])
|
||||
self.assertEqual(1, rows[1].is_public)
|
||||
self.assertEqual('public_id_old_to_new', rows[1].id)
|
||||
self.assertEqual('public', rows[1].visibility)
|
||||
|
||||
|
||||
class TestOcataExpand01MySQL(
|
||||
|
@ -127,7 +127,7 @@ class TestOcataMigrate01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
self.assertEqual(4, len(rows))
|
||||
for row in rows:
|
||||
self.assertIsNone(row['visibility'])
|
||||
self.assertIsNone(row.visibility)
|
||||
|
||||
# run data migrations
|
||||
data_migrations.migrate(engine)
|
||||
@ -139,21 +139,21 @@ class TestOcataMigrate01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
).fetchall()
|
||||
self.assertEqual(4, len(rows))
|
||||
# private_id_1 has private visibility
|
||||
self.assertEqual('private_id_1', rows[0]['id'])
|
||||
self.assertEqual('private_id_1', rows[0].id)
|
||||
# TODO(rosmaita): bug #1745003
|
||||
# self.assertEqual('private', rows[0]['visibility'])
|
||||
# self.assertEqual('private', rows[0].visibility)
|
||||
# private_id_2 has private visibility
|
||||
self.assertEqual('private_id_2', rows[1]['id'])
|
||||
self.assertEqual('private_id_2', rows[1].id)
|
||||
# TODO(rosmaita): bug #1745003
|
||||
# self.assertEqual('private', rows[1]['visibility'])
|
||||
# self.assertEqual('private', rows[1].visibility)
|
||||
# public_id has public visibility
|
||||
self.assertEqual('public_id', rows[2]['id'])
|
||||
self.assertEqual('public_id', rows[2].id)
|
||||
# TODO(rosmaita): bug #1745003
|
||||
# self.assertEqual('public', rows[2]['visibility'])
|
||||
# self.assertEqual('public', rows[2].visibility)
|
||||
# shared_id has shared visibility
|
||||
self.assertEqual('shared_id', rows[3]['id'])
|
||||
self.assertEqual('shared_id', rows[3].id)
|
||||
# TODO(rosmaita): bug #1745003
|
||||
# self.assertEqual('shared', rows[3]['visibility'])
|
||||
# self.assertEqual('shared', rows[3].visibility)
|
||||
|
||||
|
||||
class TestOcataMigrate01MySQL(
|
||||
|
@ -84,7 +84,7 @@ class TestTrainMigrate01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
self.assertEqual(2, len(rows))
|
||||
for row in rows:
|
||||
self.assertIn('"backend":', row['meta_data'])
|
||||
self.assertIn('"backend":', row.meta_data)
|
||||
|
||||
# run data migrations
|
||||
data_migrations.migrate(engine, release='train')
|
||||
@ -97,8 +97,8 @@ class TestTrainMigrate01Mixin(test_migrations.AlembicMigrationsMixin):
|
||||
|
||||
self.assertEqual(2, len(rows))
|
||||
for row in rows:
|
||||
self.assertNotIn('"backend":', row['meta_data'])
|
||||
self.assertIn('"store":', row['meta_data'])
|
||||
self.assertNotIn('"backend":', row.meta_data)
|
||||
self.assertIn('"store":', row.meta_data)
|
||||
|
||||
|
||||
class TestTrainMigrate01MySQL(
|
||||
|
@ -185,13 +185,6 @@ class WarningsFixture(pyfixtures.Fixture):
|
||||
message='The current statement is being autocommitted ',
|
||||
)
|
||||
|
||||
warnings.filterwarnings(
|
||||
'ignore',
|
||||
module='glance',
|
||||
category=sqla_exc.SADeprecationWarning,
|
||||
message='Using non-integer/slice indices on Row is deprecated ',
|
||||
)
|
||||
|
||||
# Enable general SQLAlchemy warnings also to ensure we're not doing
|
||||
# silly stuff. It's possible that we'll need to filter things out here
|
||||
# with future SQLAlchemy versions, but that's a good thing
|
||||
|
Loading…
Reference in New Issue
Block a user