1 changed files with 38 additions and 0 deletions
@ -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…
Reference in new issue