mirror of
https://github.com/fastapi/fastapi.git
synced 2026-05-24 08:16:11 -04:00
✨ Docs and tests, responses with headers and cookies (#185)
This commit is contained in:
committed by
GitHub
parent
8e3a7699a3
commit
528ef7e079
@@ -0,0 +1,12 @@
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
from response_cookies.tutorial001 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_path_operation():
|
||||
response = client.post("/cookie/")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"message": "Come to the dark side, we have cookies"}
|
||||
assert response.cookies["fakesession"] == "fake-cookie-session-value"
|
||||
@@ -0,0 +1,13 @@
|
||||
from starlette.testclient import TestClient
|
||||
|
||||
from response_headers.tutorial001 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_path_operation():
|
||||
response = client.get("/headers/")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"message": "Hello World"}
|
||||
assert response.headers["X-Cat-Dog"] == "alone in the world"
|
||||
assert response.headers["Content-Language"] == "en-US"
|
||||
Reference in New Issue
Block a user