# Path: osprofiler/drivers/base.py
# LOG = logging.getLogger(__name__)
# def get_driver(connection_string, *args, **kwargs):
#     def __init__(self, connection_str, project=None, service=None, host=None,
#                  **kwargs):
#     def notify(self, info, **kwargs):
#     def get_report(self, base_id):
#     def get_name(cls):
#     def list_traces(self, fields=None):
#     def list_error_traces(self):
#     def _build_tree(nodes):
#     def _append_results(self, trace_id, parent_id, name, project, service,
#                         host, timestamp, raw_payload=None):
#     def _parse_results(self):
#         def msec(dt):
# class Driver(object):
# 
# Path: osprofiler/tests/test.py
# class TestCase(testcase.TestCase):
# class FunctionalTestCase(TestCase):
#     def setUp(self):


from unittest import mock
from osprofiler.drivers import base
from osprofiler.tests import test


class MessagingTestCase(test.TestCase):

    @mock.patch("oslo_utils.importutils.try_import")
    def test_init_no_oslo_messaging(self, try_import_mock):
        try_import_mock.return_value = None

        self.assertRaises(
            ValueError, base.get_driver,
            "messaging://", project="project", service="service",
            host="host", context={})

    @mock.patch("oslo_utils.importutils.try_import")
    def test_init_and_notify(self, try_import_mock):
        context = "context"
        transport = "transport"
        project = "project"
        service = "service"
        host = "host"

        # emulate dynamic load of oslo.messaging library
        oslo_messaging_mock = mock.Mock()
        try_import_mock.return_value = oslo_messaging_mock

        # mock oslo.messaging APIs
        notifier_mock = mock.Mock()
        oslo_messaging_mock.Notifier.return_value = notifier_mock
        oslo_messaging_mock.get_notification_transport.return_value = transport


# Path: osprofiler/drivers/base.py
# LOG = logging.getLogger(__name__)
# def get_driver(connection_string, *args, **kwargs):
#     def __init__(self, connection_str, project=None, service=None, host=None,
#                  **kwargs):
#     def notify(self, info, **kwargs):
#     def get_report(self, base_id):
#     def get_name(cls):
#     def list_traces(self, fields=None):
#     def list_error_traces(self):
#     def _build_tree(nodes):
#     def _append_results(self, trace_id, parent_id, name, project, service,
#                         host, timestamp, raw_payload=None):
#     def _parse_results(self):
#         def msec(dt):
# class Driver(object):
# 
# Path: osprofiler/tests/test.py
# class TestCase(testcase.TestCase):
# class FunctionalTestCase(TestCase):
#     def setUp(self):


# Path: osprofiler/tests/unit/drivers/test_messaging.py
from unittest import mock
from osprofiler.drivers import base
from osprofiler.tests import test



class MessagingTestCase(test.TestCase):

    @mock.patch("oslo_utils.importutils.try_import")
    def test_init_no_oslo_messaging(self, try_import_mock):
        try_import_mock.return_value = None

        self.assertRaises(
            ValueError, base.get_driver,
            "messaging://", project="project", service="service",
            host="host", context={})

    @mock.patch("oslo_utils.importutils.try_import")
    def test_init_and_notify(self, try_import_mock):
        context = "context"
        transport = "transport"
        project = "project"
        service = "service"
        host = "host"

        # emulate dynamic load of oslo.messaging library
        oslo_messaging_mock = mock.Mock()
        try_import_mock.return_value = oslo_messaging_mock

        # mock oslo.messaging APIs
        notifier_mock = mock.Mock()
        oslo_messaging_mock.Notifier.return_value = notifier_mock
        oslo_messaging_mock.get_notification_transport.return_value = transport


        notify_func = base.get_driver(