fix(test_tutorial): fix tests to improve coverage

This commit is contained in:
Shahar Ilany 2022-08-24 22:36:44 +03:00 committed by GitHub
parent bbffb0e402
commit aacac66203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -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"}