Merge "Remove _use_db_facade()"
This commit is contained in:
commit
a89ba3ae32
@ -26,7 +26,6 @@ from neutron_lib.objects import exceptions as o_exc
|
||||
from neutron_lib.objects.extensions import standardattributes
|
||||
from oslo_config import cfg
|
||||
from oslo_db import exception as obj_exc
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import utils as db_utils
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
@ -598,15 +597,6 @@ class NeutronDbObject(NeutronObject, metaclass=DeclarativeObject):
|
||||
if is_attr_nullable:
|
||||
self[attrname] = None
|
||||
|
||||
# TODO(ihrachys) remove once we switch plugin code to enginefacade
|
||||
@staticmethod
|
||||
def _use_db_facade(context):
|
||||
try:
|
||||
enginefacade._transaction_ctx_for_context(context)
|
||||
except obj_exc.NoEngineContextEstablished:
|
||||
return False
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def db_context_writer(cls, context):
|
||||
"""Return read-write session activation decorator."""
|
||||
|
@ -1842,22 +1842,8 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
|
||||
obj.delete()
|
||||
self.assertEqual(1, mock_commit.call_count)
|
||||
|
||||
def _get_ro_txn_exit_func_name(self):
|
||||
# with no engine facade, we didn't have distinction between r/o and
|
||||
# r/w transactions and so we always call commit even for getters when
|
||||
# no facade is used
|
||||
return (
|
||||
SQLALCHEMY_CLOSE
|
||||
if self._test_class._use_db_facade else SQLALCHEMY_COMMIT)
|
||||
|
||||
def test_get_objects_single_transaction(self):
|
||||
with mock.patch(self._get_ro_txn_exit_func_name()) as mock_exit:
|
||||
with db_api.CONTEXT_READER.using(self.context):
|
||||
self._test_class.get_objects(self.context)
|
||||
self.assertEqual(1, mock_exit.call_count)
|
||||
|
||||
def test_get_objects_single_transaction_enginefacade(self):
|
||||
with mock.patch(self._get_ro_txn_exit_func_name()) as mock_exit:
|
||||
with mock.patch(SQLALCHEMY_CLOSE) as mock_exit:
|
||||
with db_api.CONTEXT_READER.using(self.context):
|
||||
self._test_class.get_objects(self.context)
|
||||
self.assertEqual(1, mock_exit.call_count)
|
||||
@ -1866,17 +1852,7 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
|
||||
obj = self._make_object(self.obj_fields[0])
|
||||
obj.create()
|
||||
|
||||
with mock.patch(self._get_ro_txn_exit_func_name()) as mock_exit:
|
||||
with db_api.CONTEXT_READER.using(self.context):
|
||||
obj = self._test_class.get_object(self.context,
|
||||
**obj._get_composite_keys())
|
||||
self.assertEqual(1, mock_exit.call_count)
|
||||
|
||||
def test_get_object_single_transaction_enginefacade(self):
|
||||
obj = self._make_object(self.obj_fields[0])
|
||||
obj.create()
|
||||
|
||||
with mock.patch(self._get_ro_txn_exit_func_name()) as mock_exit:
|
||||
with mock.patch(SQLALCHEMY_CLOSE) as mock_exit:
|
||||
with db_api.CONTEXT_READER.using(self.context):
|
||||
obj = self._test_class.get_object(self.context,
|
||||
**obj._get_composite_keys())
|
||||
|
Loading…
x
Reference in New Issue
Block a user