Browse Source

Add test for `docs_src.path_params.tutorial003b.py`

pull/14569/head
Yurii Motov 7 months ago
parent
commit
dad82d1262
  1. 38
      tests/test_tutorial/test_path_params/test_tutorial003b.py

38
tests/test_tutorial/test_path_params/test_tutorial003b.py

@ -0,0 +1,38 @@
from fastapi.testclient import TestClient
from docs_src.path_params.tutorial003b import app
client = TestClient(app)
def test_get_users():
response = client.get("/users")
assert response.status_code == 200, response.text
assert response.json() == ["Rick", "Morty"]
def test_openapi_schema():
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == {
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/users": {
"get": {
"operationId": "read_users2_users_get",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {},
},
},
"description": "Successful Response",
},
},
"summary": "Read Users2",
},
},
},
}
Loading…
Cancel
Save