test_tutorial001.py — fastapi Source File
Architecture documentation for test_tutorial001.py, a python file in the fastapi codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 306174d9_aa86_c300_fab5_8e766f077ecb["test_tutorial001.py"] 83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"] 306174d9_aa86_c300_fab5_8e766f077ecb --> 83e01a9c_50a9_bec9_6f86_8e729106de01 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] 306174d9_aa86_c300_fab5_8e766f077ecb --> a7c04dee_ee23_5891_b185_47ff6bed036d a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"] 306174d9_aa86_c300_fab5_8e766f077ecb --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a a972825e_c221_7cd4_5401_8d71dfe45de6["__init__.py"] 306174d9_aa86_c300_fab5_8e766f077ecb --> a972825e_c221_7cd4_5401_8d71dfe45de6 f4723ed0_fc8f_8312_189a_eb8084f80274["tutorial001_py39.py"] 306174d9_aa86_c300_fab5_8e766f077ecb --> f4723ed0_fc8f_8312_189a_eb8084f80274 style 306174d9_aa86_c300_fab5_8e766f077ecb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import importlib
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
def get_client() -> TestClient:
from docs_src.conditional_openapi import tutorial001_py39
importlib.reload(tutorial001_py39)
client = TestClient(tutorial001_py39.app)
return client
def test_disable_openapi(monkeypatch):
monkeypatch.setenv("OPENAPI_URL", "")
# Load the client after setting the env var
client = get_client()
response = client.get("/openapi.json")
assert response.status_code == 404, response.text
response = client.get("/docs")
assert response.status_code == 404, response.text
response = client.get("/redoc")
assert response.status_code == 404, response.text
def test_root():
client = get_client()
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello World"}
def test_default_openapi():
client = get_client()
response = client.get("/docs")
assert response.status_code == 200, response.text
response = client.get("/redoc")
assert response.status_code == 200, response.text
response = client.get("/openapi.json")
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/": {
"get": {
"summary": "Root",
"operationId": "root__get",
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
}
},
}
}
},
}
)
Domain
Subdomains
Dependencies
- __init__.py
- importlib
- inline_snapshot
- testclient.py
- tutorial001_py39.py
Source
Frequently Asked Questions
What does test_tutorial001.py do?
test_tutorial001.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in test_tutorial001.py?
test_tutorial001.py defines 4 function(s): get_client, test_default_openapi, test_disable_openapi, test_root.
What does test_tutorial001.py depend on?
test_tutorial001.py imports 5 module(s): __init__.py, importlib, inline_snapshot, testclient.py, tutorial001_py39.py.
Where is test_tutorial001.py in the architecture?
test_tutorial001.py is located at tests/test_tutorial/test_conditional_openapi/test_tutorial001.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_conditional_openapi).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free