test_app01.py — fastapi Source File
Architecture documentation for test_app01.py, a python file in the fastapi codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9["test_app01.py"] 83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> 83e01a9c_50a9_bec9_6f86_8e729106de01 65099b90_26c1_5db5_09e6_30dc0ea421e3["sys"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> 65099b90_26c1_5db5_09e6_30dc0ea421e3 5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9 752ca3d8_e45b_84ed_d1a1_588cbc236b65["dirty_equals"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> 752ca3d8_e45b_84ed_d1a1_588cbc236b65 a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> a7c04dee_ee23_5891_b185_47ff6bed036d a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style b6d4ce17_3c8b_e696_67b2_a4ae4858a6c9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import importlib
import sys
import pytest
from dirty_equals import IsAnyStr
from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import ValidationError
from pytest import MonkeyPatch
@pytest.fixture(
name="mod_name",
params=[
pytest.param("app01_py39"),
],
)
def get_mod_name(request: pytest.FixtureRequest):
return f"docs_src.settings.{request.param}.main"
@pytest.fixture(name="client")
def get_test_client(mod_name: str, monkeypatch: MonkeyPatch) -> TestClient:
if mod_name in sys.modules:
del sys.modules[mod_name]
monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
main_mod = importlib.import_module(mod_name)
return TestClient(main_mod.app)
def test_settings_validation_error(mod_name: str, monkeypatch: MonkeyPatch):
monkeypatch.delenv("ADMIN_EMAIL", raising=False)
if mod_name in sys.modules:
del sys.modules[mod_name] # pragma: no cover
with pytest.raises(ValidationError) as exc_info:
importlib.import_module(mod_name)
assert exc_info.value.errors() == [
{
"loc": ("admin_email",),
"msg": "Field required",
"type": "missing",
"input": {},
"url": IsAnyStr,
}
]
def test_app(client: TestClient):
response = client.get("/info")
data = response.json()
assert data == {
"app_name": "Awesome API",
"admin_email": "admin@example.com",
"items_per_user": 50,
}
def test_openapi_schema(client: TestClient):
response = client.get("/openapi.json")
assert response.status_code == 200, response.text
assert response.json() == snapshot(
{
"openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"},
"paths": {
"/info": {
"get": {
"operationId": "info_info_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {"application/json": {"schema": {}}},
}
},
"summary": "Info",
}
}
},
}
)
Domain
Subdomains
Functions
Dependencies
- dirty_equals
- importlib
- inline_snapshot
- pydantic
- pytest
- sys
- testclient.py
Source
Frequently Asked Questions
What does test_app01.py do?
test_app01.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_app01.py?
test_app01.py defines 5 function(s): get_mod_name, get_test_client, test_app, test_openapi_schema, test_settings_validation_error.
What does test_app01.py depend on?
test_app01.py imports 7 module(s): dirty_equals, importlib, inline_snapshot, pydantic, pytest, sys, testclient.py.
Where is test_app01.py in the architecture?
test_app01.py is located at tests/test_tutorial/test_settings/test_app01.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_settings).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free