Home / File/ test_list.py — fastapi Source File

test_list.py — fastapi Source File

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

File python FastAPI Applications 8 imports 24 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde["test_list.py"]
  9f6ffe39_b348_5643_336e_8d6ee8bb59bb["utils.py"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 9f6ffe39_b348_5643_336e_8d6ee8bb59bb
  28b7c1b7_b1b8_c344_dea4_80c78da77e28["get_body_model_name"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 28b7c1b7_b1b8_c344_dea4_80c78da77e28
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 0dda2280_3359_8460_301c_e98c77e78185
  5befe8bf_65d1_d058_6b78_4a597a8488e9["pytest"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 5befe8bf_65d1_d058_6b78_4a597a8488e9
  752ca3d8_e45b_84ed_d1a1_588cbc236b65["dirty_equals"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 752ca3d8_e45b_84ed_d1a1_588cbc236b65
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> a7c04dee_ee23_5891_b185_47ff6bed036d
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  3ddb4f07_0c59_5365_890b_2b4fea5a3dde --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  style 3ddb4f07_0c59_5365_890b_2b4fea5a3dde fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Annotated, Union

import pytest
from dirty_equals import IsOneOf, IsPartialDict
from fastapi import Body, FastAPI
from fastapi.testclient import TestClient
from pydantic import BaseModel, Field

from .utils import get_body_model_name

app = FastAPI()

# =====================================================================================
# Without aliases


@app.post("/required-list-str", operation_id="required_list_str")
async def read_required_list_str(p: Annotated[list[str], Body(embed=True)]):
    return {"p": p}


class BodyModelRequiredListStr(BaseModel):
    p: list[str]


@app.post("/model-required-list-str", operation_id="model_required_list_str")
def read_model_required_list_str(p: BodyModelRequiredListStr):
    return {"p": p.p}


@pytest.mark.parametrize(
    "path",
    ["/required-list-str", "/model-required-list-str"],
)
def test_required_list_str_schema(path: str):
    openapi = app.openapi()
    body_model_name = get_body_model_name(openapi, path)

    assert app.openapi()["components"]["schemas"][body_model_name] == {
        "properties": {
            "p": {
                "items": {"type": "string"},
                "title": "P",
                "type": "array",
            },
        },
        "required": ["p"],
        "title": body_model_name,
        "type": "object",
    }


@pytest.mark.parametrize("json", [None, {}])
@pytest.mark.parametrize(
    "path",
    ["/required-list-str", "/model-required-list-str"],
)
def test_required_list_str_missing(path: str, json: Union[dict, None]):
    client = TestClient(app)
    response = client.post(path, json=json)
// ... (374 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does test_list.py do?
test_list.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_list.py?
test_list.py defines 24 function(s): read_model_required_list_alias, read_model_required_list_alias_and_validation_alias, read_model_required_list_str, read_model_required_list_validation_alias, read_required_list_alias, read_required_list_alias_and_validation_alias, read_required_list_str, read_required_list_validation_alias, test_required_list_alias_and_validation_alias_by_alias, test_required_list_alias_and_validation_alias_by_name, and 14 more.
What does test_list.py depend on?
test_list.py imports 8 module(s): __init__.py, dirty_equals, get_body_model_name, pydantic, pytest, testclient.py, typing, utils.py.
Where is test_list.py in the architecture?
test_list.py is located at tests/test_request_params/test_body/test_list.py (domain: FastAPI, subdomain: Applications, directory: tests/test_request_params/test_body).

Analyze Your Own Codebase

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

Try Supermodel Free