Don't use .delete() on a port in unit test

The following patch will throw errors if this is done since
it's bad behavior (even though it doesn't impact this particular test).

TrivialFix

Change-Id: I9b75bdfca1cba385debfd177103314c25a23becf
This commit is contained in:
Kevin Benton 2017-01-09 09:08:25 -08:00
parent 9dea90d453
commit bf56b8586a
1 changed files with 4 additions and 1 deletions

View File

@ -57,7 +57,10 @@ class TestRevisionPlugin(test_plugin.Ml2PluginV2TestCase):
# load port into our session
port_obj = self.ctx.session.query(models_v2.Port).one()
# simulate concurrent delete in another session
nctx.get_admin_context().session.query(models_v2.Port).delete()
other_ctx = nctx.get_admin_context()
other_ctx.session.delete(
other_ctx.session.query(models_v2.Port).first()
)
# expire the port so the revision bumping code will trigger a
# lookup on its attributes and encounter an ObjectDeletedError
self.ctx.session.expire(port_obj)