committed by
Sebastián Ramírez
3 changed files with 42 additions and 1 deletions
@ -0,0 +1,28 @@ |
|||||
|
from fastapi import FastAPI |
||||
|
from starlette.testclient import TestClient |
||||
|
|
||||
|
swagger_ui_init_oauth = {"clientId": "the-foo-clients", "appName": "The Predendapp"} |
||||
|
|
||||
|
app = FastAPI(swagger_ui_init_oauth=swagger_ui_init_oauth) |
||||
|
|
||||
|
|
||||
|
@app.get("/items/") |
||||
|
async def read_items(): |
||||
|
return {"id": "foo"} |
||||
|
|
||||
|
|
||||
|
client = TestClient(app) |
||||
|
|
||||
|
|
||||
|
def test_swagger_ui(): |
||||
|
response = client.get("/docs") |
||||
|
assert response.status_code == 200 |
||||
|
print(response.text) |
||||
|
assert f"ui.initOAuth" in response.text |
||||
|
assert f'"appName": "The Predendapp"' in response.text |
||||
|
assert f'"clientId": "the-foo-clients"' in response.text |
||||
|
|
||||
|
|
||||
|
def test_response(): |
||||
|
response = client.get("/items/") |
||||
|
assert response.json() == {"id": "foo"} |
Loading…
Reference in new issue