Home / File/ test_tutorial001.py — fastapi Source File

test_tutorial001.py — fastapi Source File

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

File python FastAPI Responses 6 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  9ee9373a_b923_622d_7596_fd0836d411d9["test_tutorial001.py"]
  96e5980c_e1c1_fe65_37a8_200c2944c4b8["utils"]
  9ee9373a_b923_622d_7596_fd0836d411d9 --> 96e5980c_e1c1_fe65_37a8_200c2944c4b8
  83e01a9c_50a9_bec9_6f86_8e729106de01["importlib"]
  9ee9373a_b923_622d_7596_fd0836d411d9 --> 83e01a9c_50a9_bec9_6f86_8e729106de01
  fb2d9376_ca24_f2b2_f130_cc10e9f2e732["types"]
  9ee9373a_b923_622d_7596_fd0836d411d9 --> fb2d9376_ca24_f2b2_f130_cc10e9f2e732
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  9ee9373a_b923_622d_7596_fd0836d411d9 --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  9ee9373a_b923_622d_7596_fd0836d411d9 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  a7f4e7b0_9725_db90_5cbc_7ca8211b323a["inline_snapshot"]
  9ee9373a_b923_622d_7596_fd0836d411d9 --> a7f4e7b0_9725_db90_5cbc_7ca8211b323a
  style 9ee9373a_b923_622d_7596_fd0836d411d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import importlib
from types import ModuleType

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

from ...utils import needs_py310


@pytest.fixture(
    name="mod",
    params=[
        pytest.param("tutorial001_py39"),
        pytest.param("tutorial001_py310", marks=needs_py310),
    ],
)
def get_module(request: pytest.FixtureRequest):
    module = importlib.import_module(f"docs_src.encoder.{request.param}")
    return module


@pytest.fixture(name="client")
def get_client(mod: ModuleType):
    client = TestClient(mod.app)
    return client


def test_put(client: TestClient, mod: ModuleType):
    fake_db = mod.fake_db

    response = client.put(
        "/items/123",
        json={
            "title": "Foo",
            "timestamp": "2023-01-01T12:00:00",
            "description": "An optional description",
        },
    )
    assert response.status_code == 200
    assert "123" in fake_db
    assert fake_db["123"] == {
        "title": "Foo",
        "timestamp": "2023-01-01T12:00:00",
        "description": "An optional description",
    }


def test_put_invalid_data(client: TestClient, mod: ModuleType):
    fake_db = mod.fake_db

    response = client.put(
        "/items/345",
        json={
            "title": "Foo",
            "timestamp": "not a date",
        },
    )
    assert response.status_code == 422
    assert response.json() == {
// ... (154 more lines)

Domain

Subdomains

Dependencies

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, Responses subdomain.
What functions are defined in test_tutorial001.py?
test_tutorial001.py defines 5 function(s): get_client, get_module, test_openapi_schema, test_put, test_put_invalid_data.
What does test_tutorial001.py depend on?
test_tutorial001.py imports 6 module(s): importlib, inline_snapshot, pytest, testclient.py, types, utils.
Where is test_tutorial001.py in the architecture?
test_tutorial001.py is located at tests/test_tutorial/test_encoder/test_tutorial001.py (domain: FastAPI, subdomain: Responses, directory: tests/test_tutorial/test_encoder).

Analyze Your Own Codebase

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

Try Supermodel Free