Home / File/ test_main.py — fastapi Source File

test_main.py — fastapi Source File

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

File python FastAPI Applications 4 imports 26 functions

Entity Profile

Dependency Diagram

graph LR
  eb102b62_f4e8_8f47_de84_f7b446fa16b3["test_main.py"]
  83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"]
  eb102b62_f4e8_8f47_de84_f7b446fa16b3 --> 83e01a9c_50a9_bec9_6f86_8e729106de01
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  eb102b62_f4e8_8f47_de84_f7b446fa16b3 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  eb102b62_f4e8_8f47_de84_f7b446fa16b3 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  eb102b62_f4e8_8f47_de84_f7b446fa16b3 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style eb102b62_f4e8_8f47_de84_f7b446fa16b3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import importlib

import pytest
from fastapi.testclient import TestClient
from inline_snapshot import snapshot


@pytest.fixture(
    name="client",
    params=[
        "app_py39.main",
        "app_an_py39.main",
    ],
)
def get_client(request: pytest.FixtureRequest):
    mod = importlib.import_module(f"docs_src.bigger_applications.{request.param}")

    client = TestClient(mod.app)
    return client


def test_users_token_jessica(client: TestClient):
    response = client.get("/users?token=jessica")
    assert response.status_code == 200
    assert response.json() == [{"username": "Rick"}, {"username": "Morty"}]


def test_users_with_no_token(client: TestClient):
    response = client.get("/users")
    assert response.status_code == 422
    assert response.json() == {
        "detail": [
            {
                "type": "missing",
                "loc": ["query", "token"],
                "msg": "Field required",
                "input": None,
            }
        ]
    }


def test_users_foo_token_jessica(client: TestClient):
    response = client.get("/users/foo?token=jessica")
    assert response.status_code == 200
    assert response.json() == {"username": "foo"}


def test_users_foo_with_no_token(client: TestClient):
    response = client.get("/users/foo")
    assert response.status_code == 422
    assert response.json() == {
        "detail": [
            {
                "type": "missing",
                "loc": ["query", "token"],
                "msg": "Field required",
                "input": None,
            }
        ]
// ... (548 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_main.py do?
test_main.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_main.py?
test_main.py defines 26 function(s): get_client, test_admin, test_admin_invalid_header, test_items_bar_token_jessica, test_items_bar_with_invalid_token, test_items_plumbus_token_jessica, test_items_plumbus_with_missing_x_token_header, test_items_plumbus_with_no_token, test_items_token_jessica, test_items_with_invalid_token, and 16 more.
What does test_main.py depend on?
test_main.py imports 4 module(s): importlib, inline_snapshot, pytest, testclient.py.
Where is test_main.py in the architecture?
test_main.py is located at tests/test_tutorial/test_bigger_applications/test_main.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_bigger_applications).

Analyze Your Own Codebase

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

Try Supermodel Free