SQLAlchemy2: fix remaining issues

Remove leftover subransaction=True arguments in
some of the unit tests, and fix get_port_network_data
as result of session query is tuple instead of dict.

Closes-Bug: #2065924
Change-Id: Id87eafeb1a3bbe565ef3ee30f43d449eb0166532
This commit is contained in:
elajkat 2024-05-17 11:35:35 +02:00
parent 6bb93cae53
commit ae79362271
2 changed files with 12 additions and 12 deletions

View File

@ -161,8 +161,8 @@ class Taas_db_Mixin(taas_extension.TaasPluginBase):
return return
ns_data = { ns_data = {
'physical_network': ns['physical_network'], 'physical_network': ns[1],
'network_type': ns['network_type'] 'network_type': ns[2]
} }
return ns_data return ns_data

View File

@ -60,54 +60,54 @@ class TaaSDbTestCase(testlib_api.SqlTestCase):
def _get_tap_service(self, tap_service_id): def _get_tap_service(self, tap_service_id):
"""Helper method to retrieve tap service.""" """Helper method to retrieve tap service."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.get_tap_service(self.ctx, tap_service_id) return self.mixin.get_tap_service(self.ctx, tap_service_id)
def _get_tap_services(self): def _get_tap_services(self):
"""Helper method to retrieve all tap services.""" """Helper method to retrieve all tap services."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.get_tap_services(self.ctx) return self.mixin.get_tap_services(self.ctx)
def _create_tap_service(self, tap_service): def _create_tap_service(self, tap_service):
"""Helper method to create tap service.""" """Helper method to create tap service."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.create_tap_service(self.ctx, tap_service) return self.mixin.create_tap_service(self.ctx, tap_service)
def _update_tap_service(self, tap_service_id, tap_service): def _update_tap_service(self, tap_service_id, tap_service):
"""Helper method to update tap service.""" """Helper method to update tap service."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.update_tap_service(self.ctx, return self.mixin.update_tap_service(self.ctx,
tap_service_id, tap_service_id,
tap_service) tap_service)
def _delete_tap_service(self, tap_service_id): def _delete_tap_service(self, tap_service_id):
"""Helper method to delete tap service.""" """Helper method to delete tap service."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.delete_tap_service(self.ctx, tap_service_id) return self.mixin.delete_tap_service(self.ctx, tap_service_id)
def _get_tap_flow(self, tap_flow_id): def _get_tap_flow(self, tap_flow_id):
"""Helper method to retrieve tap flow.""" """Helper method to retrieve tap flow."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.get_tap_flow(self.ctx, tap_flow_id) return self.mixin.get_tap_flow(self.ctx, tap_flow_id)
def _get_tap_flows(self): def _get_tap_flows(self):
"""Helper method to retrieve all tap flows.""" """Helper method to retrieve all tap flows."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.get_tap_flows(self.ctx) return self.mixin.get_tap_flows(self.ctx)
def _create_tap_flow(self, tap_flow): def _create_tap_flow(self, tap_flow):
"""Helper method to create tap flow.""" """Helper method to create tap flow."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.create_tap_flow(self.ctx, tap_flow) return self.mixin.create_tap_flow(self.ctx, tap_flow)
def _update_tap_flow(self, tap_flow_id, tap_flow): def _update_tap_flow(self, tap_flow_id, tap_flow):
"""Helper method to update tap flow.""" """Helper method to update tap flow."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.update_tap_flow(self.ctx, tap_flow_id, tap_flow) return self.mixin.update_tap_flow(self.ctx, tap_flow_id, tap_flow)
def _delete_tap_flow(self, tap_flow_id): def _delete_tap_flow(self, tap_flow_id):
"""Helper method to delete tap flow.""" """Helper method to delete tap flow."""
with self.ctx.session.begin(subtransactions=True): with self.ctx.session.begin():
return self.mixin.delete_tap_flow(self.ctx, tap_flow_id) return self.mixin.delete_tap_flow(self.ctx, tap_flow_id)
def test_tap_service_get(self): def test_tap_service_get(self):