test_local_docs.py — fastapi Source File
Architecture documentation for test_local_docs.py, a python file in the fastapi codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 62047866_e337_3c14_2193_c01cbd5b91aa["test_local_docs.py"] d01056e9_3915_bd46_d8dd_a25ff9c1e35c["inspect"] 62047866_e337_3c14_2193_c01cbd5b91aa --> d01056e9_3915_bd46_d8dd_a25ff9c1e35c 6383cfb2_5918_5c8c_5124_dbbbe44fbe24["docs.py"] 62047866_e337_3c14_2193_c01cbd5b91aa --> 6383cfb2_5918_5c8c_5124_dbbbe44fbe24 609573dc_dd8d_bd61_f42b_83a7d4873d61["get_redoc_html"] 62047866_e337_3c14_2193_c01cbd5b91aa --> 609573dc_dd8d_bd61_f42b_83a7d4873d61 3705e434_dfc7_b070_aae6_93314a9b9976["get_swagger_ui_html"] 62047866_e337_3c14_2193_c01cbd5b91aa --> 3705e434_dfc7_b070_aae6_93314a9b9976 style 62047866_e337_3c14_2193_c01cbd5b91aa fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import inspect
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
def test_strings_in_generated_swagger():
sig = inspect.signature(get_swagger_ui_html)
swagger_js_url = sig.parameters.get("swagger_js_url").default # type: ignore
swagger_css_url = sig.parameters.get("swagger_css_url").default # type: ignore
swagger_favicon_url = sig.parameters.get("swagger_favicon_url").default # type: ignore
html = get_swagger_ui_html(openapi_url="/docs", title="title")
body_content = html.body.decode()
assert swagger_js_url in body_content
assert swagger_css_url in body_content
assert swagger_favicon_url in body_content
def test_strings_in_custom_swagger():
swagger_js_url = "swagger_fake_file.js"
swagger_css_url = "swagger_fake_file.css"
swagger_favicon_url = "swagger_fake_file.png"
html = get_swagger_ui_html(
openapi_url="/docs",
title="title",
swagger_js_url=swagger_js_url,
swagger_css_url=swagger_css_url,
swagger_favicon_url=swagger_favicon_url,
)
body_content = html.body.decode()
assert swagger_js_url in body_content
assert swagger_css_url in body_content
assert swagger_favicon_url in body_content
def test_strings_in_generated_redoc():
sig = inspect.signature(get_redoc_html)
redoc_js_url = sig.parameters.get("redoc_js_url").default # type: ignore
redoc_favicon_url = sig.parameters.get("redoc_favicon_url").default # type: ignore
html = get_redoc_html(openapi_url="/docs", title="title")
body_content = html.body.decode()
assert redoc_js_url in body_content
assert redoc_favicon_url in body_content
def test_strings_in_custom_redoc():
redoc_js_url = "fake_redoc_file.js"
redoc_favicon_url = "fake_redoc_file.png"
html = get_redoc_html(
openapi_url="/docs",
title="title",
redoc_js_url=redoc_js_url,
redoc_favicon_url=redoc_favicon_url,
)
body_content = html.body.decode()
assert redoc_js_url in body_content
assert redoc_favicon_url in body_content
def test_google_fonts_in_generated_redoc():
body_with_google_fonts = get_redoc_html(
openapi_url="/docs", title="title"
).body.decode()
assert "fonts.googleapis.com" in body_with_google_fonts
body_without_google_fonts = get_redoc_html(
openapi_url="/docs", title="title", with_google_fonts=False
).body.decode()
assert "fonts.googleapis.com" not in body_without_google_fonts
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does test_local_docs.py do?
test_local_docs.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_local_docs.py?
test_local_docs.py defines 5 function(s): test_google_fonts_in_generated_redoc, test_strings_in_custom_redoc, test_strings_in_custom_swagger, test_strings_in_generated_redoc, test_strings_in_generated_swagger.
What does test_local_docs.py depend on?
test_local_docs.py imports 4 module(s): docs.py, get_redoc_html, get_swagger_ui_html, inspect.
Where is test_local_docs.py in the architecture?
test_local_docs.py is located at tests/test_local_docs.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