# Path: oslo_db/concurrency.py
# LOG = logging.getLogger(__name__)
# class TpoolDbapiWrapper(object):
#     def __init__(self, conf, backend_mapping):
#     def _api(self):
#     def __getattr__(self, key):
# def list_opts():
# 
# Path: oslo_db/tests/base.py
# class BaseTestCase(base.BaseTestCase):
#     def setUp(self):


import sys
from unittest import mock
from oslo_config import fixture as config_fixture
from oslo_db import concurrency
from oslo_db.tests import base as test_base
        # the following reasons:
        #  - supporting of eventlet's thread pooling is totally optional;
        #  - we don't need to test `tpool.Proxy` functionality itself,
        #    because it's a tool from the third party library;
        #  - `eventlet` would prevent us from running unit tests on Python 3.x
        #    versions, because it doesn't support them yet.
        #
        # As we don't test `tpool.Proxy`, we can safely mock it in tests.

        self.proxy = mock.MagicMock()
        self.eventlet = mock.MagicMock()
        self.eventlet.tpool.Proxy.return_value = self.proxy
        sys.modules['eventlet'] = self.eventlet
        self.addCleanup(sys.modules.pop, 'eventlet', None)

    @mock.patch('oslo_db.api.DBAPI')
    def test_db_api_common(self, mock_db_api):
        # test context:
        #     CONF.database.use_tpool == False
        #     eventlet is installed
        # expected result:
        #     TpoolDbapiWrapper should wrap DBAPI

        fake_db_api = mock.MagicMock()
        mock_db_api.from_config.return_value = fake_db_api

        # get access to some db-api method
        self.db_api.fake_call_1

        mock_db_api.from_config.assert_called_once_with(

# Path: oslo_db/concurrency.py
# LOG = logging.getLogger(__name__)
# class TpoolDbapiWrapper(object):
#     def __init__(self, conf, backend_mapping):
#     def _api(self):
#     def __getattr__(self, key):
# def list_opts():
# 
# Path: oslo_db/tests/base.py
# class BaseTestCase(base.BaseTestCase):
#     def setUp(self):


# Path: oslo_db/tests/test_concurrency.py
import sys
from unittest import mock
from oslo_config import fixture as config_fixture
from oslo_db import concurrency
from oslo_db.tests import base as test_base

        # the following reasons:
        #  - supporting of eventlet's thread pooling is totally optional;
        #  - we don't need to test `tpool.Proxy` functionality itself,
        #    because it's a tool from the third party library;
        #  - `eventlet` would prevent us from running unit tests on Python 3.x
        #    versions, because it doesn't support them yet.
        #
        # As we don't test `tpool.Proxy`, we can safely mock it in tests.

        self.proxy = mock.MagicMock()
        self.eventlet = mock.MagicMock()
        self.eventlet.tpool.Proxy.return_value = self.proxy
        sys.modules['eventlet'] = self.eventlet
        self.addCleanup(sys.modules.pop, 'eventlet', None)

    @mock.patch('oslo_db.api.DBAPI')
    def test_db_api_common(self, mock_db_api):
        # test context:
        #     CONF.database.use_tpool == False
        #     eventlet is installed
        # expected result:
        #     TpoolDbapiWrapper should wrap DBAPI

        fake_db_api = mock.MagicMock()
        mock_db_api.from_config.return_value = fake_db_api

        # get access to some db-api method
        self.db_api.fake_call_1

        mock_db_api.from_config.assert_called_once_with(

            conf=self.conf, backend_mapping=FAKE_BACKEND_MAPPING)