diff --git a/tests/test_tutorial/test_extending_openapi/test_tutorial002.py b/tests/test_tutorial/test_extending_openapi/test_tutorial002.py index 654db2e4c..e7fd48eec 100644 --- a/tests/test_tutorial/test_extending_openapi/test_tutorial002.py +++ b/tests/test_tutorial/test_extending_openapi/test_tutorial002.py @@ -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 diff --git a/tests/test_tutorial/test_extending_openapi/test_tutorial006.py b/tests/test_tutorial/test_extending_openapi/test_tutorial006.py new file mode 100644 index 000000000..34aad3d6e --- /dev/null +++ b/tests/test_tutorial/test_extending_openapi/test_tutorial006.py @@ -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"}