Home / File/ test_app03.py — fastapi Source File

test_app03.py — fastapi Source File

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

File python FastAPI Applications 4 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  5f630c1f_bd1e_7421_eded_f50460e61505["test_app03.py"]
  83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"]
  5f630c1f_bd1e_7421_eded_f50460e61505 --> 83e01a9c_50a9_bec9_6f86_8e729106de01
  fb2d9376_ca24_f2b2_f130_cc10e9f2e732["types"]
  5f630c1f_bd1e_7421_eded_f50460e61505 --> fb2d9376_ca24_f2b2_f130_cc10e9f2e732
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  5f630c1f_bd1e_7421_eded_f50460e61505 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  5f630c1f_bd1e_7421_eded_f50460e61505 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  style 5f630c1f_bd1e_7421_eded_f50460e61505 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import importlib
from types import ModuleType

import pytest
from fastapi.testclient import TestClient
from pytest import MonkeyPatch


@pytest.fixture(
    name="mod_path",
    params=[
        pytest.param("app03_py39"),
        pytest.param("app03_an_py39"),
    ],
)
def get_mod_path(request: pytest.FixtureRequest):
    mod_path = f"docs_src.settings.{request.param}"
    return mod_path


@pytest.fixture(name="main_mod")
def get_main_mod(mod_path: str) -> ModuleType:
    main_mod = importlib.import_module(f"{mod_path}.main")
    return main_mod


def test_settings(main_mod: ModuleType, monkeypatch: MonkeyPatch):
    monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
    settings = main_mod.get_settings()
    assert settings.app_name == "Awesome API"
    assert settings.admin_email == "admin@example.com"
    assert settings.items_per_user == 50


def test_endpoint(main_mod: ModuleType, monkeypatch: MonkeyPatch):
    monkeypatch.setenv("ADMIN_EMAIL", "admin@example.com")
    client = TestClient(main_mod.app)
    response = client.get("/info")
    assert response.status_code == 200
    assert response.json() == {
        "app_name": "Awesome API",
        "admin_email": "admin@example.com",
        "items_per_user": 50,
    }

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_app03.py do?
test_app03.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_app03.py?
test_app03.py defines 4 function(s): get_main_mod, get_mod_path, test_endpoint, test_settings.
What does test_app03.py depend on?
test_app03.py imports 4 module(s): importlib, pytest, testclient.py, types.
Where is test_app03.py in the architecture?
test_app03.py is located at tests/test_tutorial/test_settings/test_app03.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