# Path: tests/compat.py
# class RequestFactory:
#     def method(self, method, url, params, body=None, root_path=None, **headers):
#         from flask.ctx import AppContext
#         from flask import Flask
#         import os
#         if not root_path:
#             root_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib/tri_form/', )
#         app = AppContext(Flask('tri_form', root_path=root_path))
#         app.push()
#         from werkzeug.test import create_environ
#         from tri_form.compat import HttpRequest
# 
#         # We use the django style where headers are HTTP_
#         for k, v in headers.items():
#             assert k.startswith('HTTP_')
# 
#         # ...but flask adds HTTP_ itself, so we have to cut them off here
#         headers = {k[len('HTTP_'):]: v for k, v in headers.items()}
# 
#         return HttpRequest(create_environ(path=url, query_string=params, method=method, data=body, headers=headers))
# 
#     def get(self, url, params=None, **headers):
#         return self.method('GET', url, params=params, **headers)
# 
#     def post(self, url, params=None, **headers):
#         return self.method('POST', url, params={}, body=params, **headers)


from tri_struct import Struct
from tri_form import handle_dispatch, DISPATCH_PATH_SEPARATOR
from .compat import RequestFactory


def test_handle_dispatch_no_dispatch():
    request = RequestFactory().get('/', dict(foo='asds'))
    assert handle_dispatch(request, None) == (False, None)



# Path: tests/compat.py
# class RequestFactory:
#     def method(self, method, url, params, body=None, root_path=None, **headers):
#         from flask.ctx import AppContext
#         from flask import Flask
#         import os
#         if not root_path:
#             root_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib/tri_form/', )
#         app = AppContext(Flask('tri_form', root_path=root_path))
#         app.push()
#         from werkzeug.test import create_environ
#         from tri_form.compat import HttpRequest
# 
#         # We use the django style where headers are HTTP_
#         for k, v in headers.items():
#             assert k.startswith('HTTP_')
# 
#         # ...but flask adds HTTP_ itself, so we have to cut them off here
#         headers = {k[len('HTTP_'):]: v for k, v in headers.items()}
# 
#         return HttpRequest(create_environ(path=url, query_string=params, method=method, data=body, headers=headers))
# 
#     def get(self, url, params=None, **headers):
#         return self.method('GET', url, params=params, **headers)
# 
#     def post(self, url, params=None, **headers):
#         return self.method('POST', url, params={}, body=params, **headers)


# Path: tests/test_misc.py
from tri_struct import Struct
from tri_form import handle_dispatch, DISPATCH_PATH_SEPARATOR
from .compat import RequestFactory



def test_handle_dispatch_no_dispatch():
    request = RequestFactory().get('/', dict(foo='asds'))
    assert handle_dispatch(request, None) == (False, None)



def test_handle_dispatch_one_level():