From a3d0fb6673db9ac5b127aea2c4e4f58c5887564c Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 7 May 2024 21:27:50 -0400 Subject: [PATCH] tests: Don't use neutron object where db model is expected Change-Id: I5f99153c105e7f86638356a75a955504ed42e288 --- .../tests/unit/services/revisions/test_revision_plugin.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/neutron/tests/unit/services/revisions/test_revision_plugin.py b/neutron/tests/unit/services/revisions/test_revision_plugin.py index 7d9cc9a5ddd..f5a775e396d 100644 --- a/neutron/tests/unit/services/revisions/test_revision_plugin.py +++ b/neutron/tests/unit/services/revisions/test_revision_plugin.py @@ -24,7 +24,6 @@ from sqlalchemy.orm import session as se from webob import exc from neutron.db import models_v2 -from neutron.objects import ports as port_obj from neutron.tests.unit.plugins.ml2 import test_plugin @@ -67,10 +66,7 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase): rp = directory.get_plugin('revision_plugin') with self.port(): with db_api.CONTEXT_WRITER.using(self.ctx): - ipal_objs = port_obj.IPAllocation.get_objects(self.ctx) - if not ipal_objs: - raise Exception("No IP allocations available.") - ipal_obj = ipal_objs[0] + ipal = self.ctx.session.query(models_v2.IPAllocation).first() # load port into our session port = self.ctx.session.query(models_v2.Port).one() # simulate concurrent delete in another session @@ -86,7 +82,7 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase): self.ctx.session.expire(port) collected = rp._collect_related_tobump( - self.ctx.session, [ipal_obj], set()) + self.ctx.session, [ipal], set()) rp._bump_obj_revisions( self.ctx.session, collected, version_check=False)