mirror of https://github.com/tiangolo/fastapi.git
fix(test_tutorial): fix tests to improve coverage
This commit is contained in:
parent
bbffb0e402
commit
aacac66203
|
|
@ -36,6 +36,13 @@ def test_redoc_html(client: TestClient):
|
|||
assert "/static/redoc.standalone.js" in response.text
|
||||
|
||||
|
||||
def test_elements_html(client: TestClient):
|
||||
response = client.get("/elements")
|
||||
assert response.status_code == 200, response.text
|
||||
assert "/static/web-components.min.js" in response.text
|
||||
assert "/static/styles.min.css" in response.text
|
||||
|
||||
|
||||
def test_api(client: TestClient):
|
||||
response = client.get("/users/john")
|
||||
assert response.status_code == 200, response.text
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
from fastapi.testclient import TestClient
|
||||
|
||||
from docs_src.extending_openapi.tutorial006 import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_swagger_ui():
|
||||
response = client.get("/elements")
|
||||
assert response.status_code == 200, response.text
|
||||
assert 'router="history"' in response.text
|
||||
assert 'layout="sidebar"' in response.text
|
||||
assert 'tryItCredentialPolicy="omit"' in response.text
|
||||
|
||||
|
||||
|
||||
def test_get_users():
|
||||
response = client.get("/users/foo")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == {"message": "Hello foo"}
|
||||
Loading…
Reference in New Issue