예제 #1
0
 def test_get_method_from_original_request(self, app, method):
     with app.test_request_context(base_url='http://localhost/',
                                   path='/path/file.json',
                                   query_string='arg1=1&arg2=2',
                                   method=method,
                                   headers={'header': 'value'}):
         request = IncomingFlaskRequest(flask.request)
         assert request.method == method
예제 #2
0
 def test_cookies_are_parsed_to_dict(self, app):
     with app.test_request_context(base_url='http://localhost/',
                                   path='/path/file.json',
                                   query_string='arg1=1&arg2=2',
                                   method='GET',
                                   headers={'header': 'value'}):
         request = IncomingFlaskRequest(flask.request)
         assert len(request.cookies) == 0
예제 #3
0
 def test_get_url_combines_all_parts(self, app):
     with app.test_request_context(base_url='http://localhost/',
                                   path='/path/file.json',
                                   query_string='arg1=1&arg2=2',
                                   method='GET',
                                   headers={'header': 'value'}):
         request = IncomingFlaskRequest(flask.request)
         assert request.url == 'http://localhost/path/file.json?arg1=1&arg2=2'
예제 #4
0
 def test_parse_query_to_args(self, app):
     with app.test_request_context(base_url='http://localhost/',
                                   path='/path/file.json',
                                   query_string='arg1=1&arg2=2',
                                   method='GET',
                                   headers={'header': 'value'}):
         request = IncomingFlaskRequest(flask.request)
         assert request.args['arg1'] == '1'
         assert request.args['arg2'] == '2'
예제 #5
0
def respond(path: str) -> Response:
    """Match request againts defined routes and return appropriet response."""
    incomming_request = IncomingFlaskRequest(request)
    try:
        if route := current_app.user_router.match(incomming_request):
            route.authenticate(incomming_request)
            response = route.select_response()
            route.use(response)
            response.wait()
            context = ResponseContext({})
            return response.as_flask_response(context)
        abort(404)