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 == {}
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
def handler4(request, id): return Response("test4 - {}".format(id))
def handler3(request): return Response("test3")
def handler1(request): return Response("test1")
def multipart_app(request): return Response()
def form_app(request): return Response()
def get_app(request): return Response()
def json_app7(request): response = Response(getattr(request, "raw_body", b"not exist"), headers={"Content-Type": "text/plain"}) return response
def json_app5(request): response = Response("not-dict-or-list-value", headers={"Content-Type": "text/plain"}) return response
def json_app4(request): response = Response({"test": "test value"}, headers={"Content-Type": "text/plain"}) return response
def json_app3(request): response = Response(request.body, headers={"Content-Type": "text/plain"}) return response
def json_app2(request): response = Response({"test": "test value"}, headers={"Content-Type": "application/json"}) return response
def session_app(request): request.session["test"] = request.session.get("test", 0) + 1 response = Response(request.session["test"]) return response
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()