Fix test_migrations with firmware information.
Two issues existed in our test migrations: 1) We took a sqlalchemy orm-ey object and returned it. The handler closed but the connection stays open. 2) In the test we mocked data, saved data, checked data, but there is a constraint that would prevent nodes from being deleted before the firmware_information data. Also fixes some additional assignment of object value pattern of usage elsewhere in the test migrations as pointed out in code review. Co-Authored-By: Jay Faulkner <jay@jvf.cc> Change-Id: I91429f33ce01f40ecd665b2f76b27a162354bc6f
This commit is contained in:
parent
2f8ee2cf40
commit
3d869bca26
@ -719,7 +719,9 @@ class MigrationCheckersMixin(object):
|
||||
models.Node.uuid == data['uuid']
|
||||
)
|
||||
node = connection.execute(node_stmt).first()
|
||||
data['id'] = node.id
|
||||
# WARNING: Always copy, never directly return a db object or
|
||||
# piece of a db object. It is a sqlalchemy thing.
|
||||
data['id'] = int(node.id)
|
||||
return data
|
||||
|
||||
def _check_b4130a7fc904(self, engine, data):
|
||||
@ -755,7 +757,9 @@ class MigrationCheckersMixin(object):
|
||||
models.Node.id
|
||||
).where(models.Node.uuid == data['uuid'])
|
||||
node = connection.execute(node_stmt).first()
|
||||
data['id'] = node.id
|
||||
# WARNING: Always copy, never directly return a db object or
|
||||
# piece of a db object. It is a sqlalchemy thing.
|
||||
data['id'] = int(node.id)
|
||||
return data
|
||||
|
||||
def _check_82c315d60161(self, engine, data):
|
||||
@ -1274,7 +1278,9 @@ class MigrationCheckersMixin(object):
|
||||
models.Node.id
|
||||
).where(models.Node.uuid == data['uuid'])
|
||||
node = connection.execute(node_stmt).first()
|
||||
data['id'] = node.id
|
||||
# WARNING: Always copy, never directly return a db object or
|
||||
# piece of a db object. It is a sqlalchemy thing.
|
||||
data['id'] = int(node.id)
|
||||
|
||||
return data
|
||||
|
||||
@ -1324,6 +1330,12 @@ class MigrationCheckersMixin(object):
|
||||
)
|
||||
fw_component = connection.execute(fw_cmp_stmt).first()
|
||||
self.assertEqual('v1.0.0', fw_component['initial_version'])
|
||||
del_stmt = (
|
||||
sqlalchemy.delete(
|
||||
models.FirmwareInformation
|
||||
).where(models.FirmwareInformation.node_id == data['id'])
|
||||
)
|
||||
connection.execute(del_stmt)
|
||||
|
||||
def test_upgrade_and_version(self):
|
||||
with patch_with_engine(self.engine):
|
||||
|
Loading…
Reference in New Issue
Block a user