fastapi-master/tests/test_tutorial/test_testing/test_main.py

29 lines
819 B
Python
Raw Normal View History

2024-08-24 12:41:47 +08:00
from docs_src.app_testing.test_main import client, test_read_main
def test_main():
test_read_main()
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": {
"/": {
"get": {
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
}
},
"summary": "Read Main",
"operationId": "read_main__get",
}
}
},
}