# Path: osprofiler/_utils.py
# def split(text, strip=True):
# def binary_encode(text, encoding="utf-8"):
# def binary_decode(data, encoding="utf-8"):
# def generate_hmac(data, hmac_key):
# def signed_pack(data, hmac_key):
# def signed_unpack(data, hmac_data, hmac_keys):
# def itersubclasses(cls, _seen=None):
# def import_modules_from_package(package):
# def shorten_id(span_id):
# 
# Path: osprofiler/profiler.py
# def clean():
# def _ensure_no_multiple_traced(traceable_attrs):
# def init(hmac_key, base_id=None, parent_id=None):
# def get():
# def start(name, info=None):
# def stop(info=None):
# def trace(name, info=None, hide_args=False, hide_result=True,
#           allow_multiple_trace=True):
#     def decorator(f):
#         def wrapper(*args, **kwargs):
# def trace_cls(name, info=None, hide_args=False, hide_result=True,
#               trace_private=False, allow_multiple_trace=True,
#               trace_class_methods=False, trace_static_methods=False):
#     def trace_checker(attr_name, to_be_wrapped):
#     def decorator(cls):
#     def __init__(cls, cls_name, bases, attrs):
#     def __init__(self, name, info=None):
#     def __enter__(self):
#     def __exit__(self, etype, value, traceback):
#     def __init__(self, hmac_key, base_id=None, parent_id=None):
#     def get_shorten_id(self, uuid_id):
#     def get_base_id(self):
#     def get_parent_id(self):
#     def get_id(self):
#     def start(self, name, info=None):
#     def stop(self, info=None):
#     def _notify(self, name, info):
# class TracedMeta(type):
# class Trace(object):
# class _Profiler(object):
# 
# Path: osprofiler/tests/test.py
# class TestCase(testcase.TestCase):
# class FunctionalTestCase(TestCase):
#     def setUp(self):
# 
# Path: osprofiler/web.py
# _REQUIRED_KEYS = ("base_id", "hmac_key")
# _OPTIONAL_KEYS = ("parent_id",)
# X_TRACE_INFO = "X-Trace-Info"
# X_TRACE_HMAC = "X-Trace-HMAC"
# _ENABLED = None
# _HMAC_KEYS = None
#     _ENABLED = False
#     _ENABLED = True
#     _HMAC_KEYS = utils.split(hmac_keys or "")
# def get_trace_id_headers():
# def disable():
# def enable(hmac_keys=None):
#     def __init__(self, application, hmac_keys=None, enabled=False, **kwargs):
#     def factory(cls, global_conf, **local_conf):
#         def filter_(app):
#     def _trace_is_valid(self, trace_info):
#     def __call__(self, request):
# class WsgiMiddleware(object):


from unittest import mock
from webob import response as webob_response
from osprofiler import _utils as utils
from osprofiler import profiler
from osprofiler.tests import test
from osprofiler import web
        request = mock.MagicMock()
        request.get_response.return_value = "yeah!"
        request.url = "someurl"
        request.host_url = "someurl"
        request.path = "path"
        request.query_string = "query"
        request.method = "method"
        request.scheme = "scheme"
        hmac_key = "super_secret_key2"

        pack = utils.signed_pack({"base_id": "1", "parent_id": "2"}, hmac_key)
        request.headers = {
            "a": "1",
            "b": "2",
            "X-Trace-Info": pack[0],
            "X-Trace-HMAC": pack[1]
        }

        web.enable("super_secret_key1,super_secret_key2")
        middleware = web.WsgiMiddleware("app", enabled=True)
        self.assertEqual("yeah!", middleware(request))
        mock_profiler_init.assert_called_once_with(hmac_key=hmac_key,
                                                   base_id="1",
                                                   parent_id="2")

    def test_disable(self):
        web.disable()
        self.assertFalse(web._ENABLED)

    def test_enabled(self):

# Path: osprofiler/_utils.py
# def split(text, strip=True):
# def binary_encode(text, encoding="utf-8"):
# def binary_decode(data, encoding="utf-8"):
# def generate_hmac(data, hmac_key):
# def signed_pack(data, hmac_key):
# def signed_unpack(data, hmac_data, hmac_keys):
# def itersubclasses(cls, _seen=None):
# def import_modules_from_package(package):
# def shorten_id(span_id):
# 
# Path: osprofiler/profiler.py
# def clean():
# def _ensure_no_multiple_traced(traceable_attrs):
# def init(hmac_key, base_id=None, parent_id=None):
# def get():
# def start(name, info=None):
# def stop(info=None):
# def trace(name, info=None, hide_args=False, hide_result=True,
#           allow_multiple_trace=True):
#     def decorator(f):
#         def wrapper(*args, **kwargs):
# def trace_cls(name, info=None, hide_args=False, hide_result=True,
#               trace_private=False, allow_multiple_trace=True,
#               trace_class_methods=False, trace_static_methods=False):
#     def trace_checker(attr_name, to_be_wrapped):
#     def decorator(cls):
#     def __init__(cls, cls_name, bases, attrs):
#     def __init__(self, name, info=None):
#     def __enter__(self):
#     def __exit__(self, etype, value, traceback):
#     def __init__(self, hmac_key, base_id=None, parent_id=None):
#     def get_shorten_id(self, uuid_id):
#     def get_base_id(self):
#     def get_parent_id(self):
#     def get_id(self):
#     def start(self, name, info=None):
#     def stop(self, info=None):
#     def _notify(self, name, info):
# class TracedMeta(type):
# class Trace(object):
# class _Profiler(object):
# 
# Path: osprofiler/tests/test.py
# class TestCase(testcase.TestCase):
# class FunctionalTestCase(TestCase):
#     def setUp(self):
# 
# Path: osprofiler/web.py
# _REQUIRED_KEYS = ("base_id", "hmac_key")
# _OPTIONAL_KEYS = ("parent_id",)
# X_TRACE_INFO = "X-Trace-Info"
# X_TRACE_HMAC = "X-Trace-HMAC"
# _ENABLED = None
# _HMAC_KEYS = None
#     _ENABLED = False
#     _ENABLED = True
#     _HMAC_KEYS = utils.split(hmac_keys or "")
# def get_trace_id_headers():
# def disable():
# def enable(hmac_keys=None):
#     def __init__(self, application, hmac_keys=None, enabled=False, **kwargs):
#     def factory(cls, global_conf, **local_conf):
#         def filter_(app):
#     def _trace_is_valid(self, trace_info):
#     def __call__(self, request):
# class WsgiMiddleware(object):


# Path: osprofiler/tests/unit/test_web.py
from unittest import mock
from webob import response as webob_response
from osprofiler import _utils as utils
from osprofiler import profiler
from osprofiler.tests import test
from osprofiler import web

        request = mock.MagicMock()
        request.get_response.return_value = "yeah!"
        request.url = "someurl"
        request.host_url = "someurl"
        request.path = "path"
        request.query_string = "query"
        request.method = "method"
        request.scheme = "scheme"
        hmac_key = "super_secret_key2"

        pack = utils.signed_pack({"base_id": "1", "parent_id": "2"}, hmac_key)
        request.headers = {
            "a": "1",
            "b": "2",
            "X-Trace-Info": pack[0],
            "X-Trace-HMAC": pack[1]
        }

        web.enable("super_secret_key1,super_secret_key2")
        middleware = web.WsgiMiddleware("app", enabled=True)
        self.assertEqual("yeah!", middleware(request))
        mock_profiler_init.assert_called_once_with(hmac_key=hmac_key,
                                                   base_id="1",
                                                   parent_id="2")

    def test_disable(self):
        web.disable()
        self.assertFalse(web._ENABLED)

    def test_enabled(self):

        web.disable()