Home / File/ test_custom_swagger_ui_redirect.py — fastapi Source File

test_custom_swagger_ui_redirect.py — fastapi Source File

Architecture documentation for test_custom_swagger_ui_redirect.py, a python file in the fastapi codebase. 2 imports, 0 dependents.

File python FastAPI Responses 2 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  c7f398ca_88a4_824a_0de6_f116e3d85e08["test_custom_swagger_ui_redirect.py"]
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  c7f398ca_88a4_824a_0de6_f116e3d85e08 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  c7f398ca_88a4_824a_0de6_f116e3d85e08 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style c7f398ca_88a4_824a_0de6_f116e3d85e08 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from fastapi import FastAPI
from fastapi.testclient import TestClient

swagger_ui_oauth2_redirect_url = "/docs/redirect"

app = FastAPI(swagger_ui_oauth2_redirect_url=swagger_ui_oauth2_redirect_url)


@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, response.text
    assert response.headers["content-type"] == "text/html; charset=utf-8"
    assert "swagger-ui-dist" in response.text
    print(client.base_url)
    assert (
        f"oauth2RedirectUrl: window.location.origin + '{swagger_ui_oauth2_redirect_url}'"
        in response.text
    )


def test_swagger_ui_oauth2_redirect():
    response = client.get(swagger_ui_oauth2_redirect_url)
    assert response.status_code == 200, response.text
    assert response.headers["content-type"] == "text/html; charset=utf-8"
    assert "window.opener.swaggerUIRedirectOauth2" in response.text


def test_response():
    response = client.get("/items/")
    assert response.json() == {"id": "foo"}

Domain

Subdomains

Frequently Asked Questions

What does test_custom_swagger_ui_redirect.py do?
test_custom_swagger_ui_redirect.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in test_custom_swagger_ui_redirect.py?
test_custom_swagger_ui_redirect.py defines 4 function(s): read_items, test_response, test_swagger_ui, test_swagger_ui_oauth2_redirect.
What does test_custom_swagger_ui_redirect.py depend on?
test_custom_swagger_ui_redirect.py imports 2 module(s): __init__.py, testclient.py.
Where is test_custom_swagger_ui_redirect.py in the architecture?
test_custom_swagger_ui_redirect.py is located at tests/test_custom_swagger_ui_redirect.py (domain: FastAPI, subdomain: Responses, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free