def test_base_cookie_storage_persist_session_with_cookies():
    storage = DummyCookieStorage()
    request = Request()
    response = Response()
    response.cookies = {}
    storage.persist_session_key(request, response, _SessionKey(100))
    assert response.cookies['session-id']['value'] == 100
def test_base_cookie_storage_persist_session_without_changing_the_session_key():
    storage = DummyCookieStorage()
    request = Request()
    request.cookies = {"session-id": {"value": ["test"]}}
    response = Response()
    response.cookies = {}
    storage.persist_session_key(request, response, _SessionKey(100))
    assert response.cookies['session-id']['value'] == 100

    request.cookies = response.cookies
    response.cookies = {}
    storage.persist_session_key(request, response, _SessionKey(100))
    assert response.cookies == {}
Esempio n. 3
0
def cookie_app(request):
    response = Response(request.cookies if request.cookies else "No Cookie",
                        headers={"Content-Type": 'text/plain'},
                        cookies={'test': {
                            'value': 'test'
                        }})
    return response
Esempio n. 4
0
def handler4(request, id):
    return Response("test4 - {}".format(id))
Esempio n. 5
0
def handler3(request):
    return Response("test3")
Esempio n. 6
0
def handler1(request):
    return Response("test1")
Esempio n. 7
0
def multipart_app(request):
    return Response()
Esempio n. 8
0
def form_app(request):
    return Response()
Esempio n. 9
0
def get_app(request):
    return Response()
Esempio n. 10
0
def json_app7(request):
    response = Response(getattr(request, "raw_body", b"not exist"),
                        headers={"Content-Type": "text/plain"})
    return response
Esempio n. 11
0
def json_app5(request):
    response = Response("not-dict-or-list-value",
                        headers={"Content-Type": "text/plain"})
    return response
Esempio n. 12
0
def json_app4(request):
    response = Response({"test": "test value"},
                        headers={"Content-Type": "text/plain"})
    return response
Esempio n. 13
0
def json_app3(request):
    response = Response(request.body,
                        headers={"Content-Type": "text/plain"})
    return response
Esempio n. 14
0
def json_app2(request):
    response = Response({"test": "test value"},
                        headers={"Content-Type": "application/json"})
    return response
Esempio n. 15
0
def session_app(request):
    request.session["test"] = request.session.get("test", 0) + 1
    response = Response(request.session["test"])
    return response
Esempio n. 16
0
def session_app(request):
    if request.headers['in-test'] == "in-test-other-value":
        return Response(headers={"out-test": "out-test-other-value"})
    else:
        return Response()