mirror of https://github.com/tiangolo/fastapi.git
Remove Json[list[str]] test for Cookie
This commit is contained in:
parent
cb8cb442b9
commit
690f8d23c9
|
|
@ -1,7 +1,7 @@
|
|||
import json
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Cookie, FastAPI, Form, Header, Query
|
||||
from fastapi import FastAPI, Form, Header, Query
|
||||
from fastapi.testclient import TestClient
|
||||
from pydantic import Json
|
||||
|
||||
|
|
@ -23,13 +23,6 @@ def header_json_list(x_items: Annotated[Json[list[str]], Header()]) -> list[str]
|
|||
return x_items
|
||||
|
||||
|
||||
@app.get("/cookie-json-dict")
|
||||
def cookie_json_dict(
|
||||
session: Annotated[Json[dict[str, str]], Cookie()],
|
||||
) -> dict[str, str]:
|
||||
return session
|
||||
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
|
|
@ -55,10 +48,3 @@ def test_header_json_list():
|
|||
)
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == ["abc", "def"]
|
||||
|
||||
|
||||
def test_cookie_json_dict():
|
||||
client.cookies.set("session", json.dumps({"user": "test1", "role": "admin"}))
|
||||
response = client.get("/cookie-json-dict")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {"user": "test1", "role": "admin"}
|
||||
|
|
|
|||
Loading…
Reference in New Issue