Home / Function/ test_read_with_orm_mode() — fastapi Function Reference

test_read_with_orm_mode() — fastapi Function Reference

Architecture documentation for the test_read_with_orm_mode() function in test_read_with_orm_mode.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  84ed8977_eb45_c490_06c3_422477ef46bb["test_read_with_orm_mode()"]
  6b69f20f_51b6_8288_b805_c2d8380f5274["test_read_with_orm_mode.py"]
  84ed8977_eb45_c490_06c3_422477ef46bb -->|defined in| 6b69f20f_51b6_8288_b805_c2d8380f5274
  fcd8c455_0f7f_7ed7_af28_3f71f6db7165["full_name()"]
  84ed8977_eb45_c490_06c3_422477ef46bb -->|calls| fcd8c455_0f7f_7ed7_af28_3f71f6db7165
  style 84ed8977_eb45_c490_06c3_422477ef46bb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_read_with_orm_mode.py lines 8–43

def test_read_with_orm_mode() -> None:
    class PersonBase(BaseModel):
        name: str
        lastname: str

    class Person(PersonBase):
        @property
        def full_name(self) -> str:
            return f"{self.name} {self.lastname}"

        model_config = ConfigDict(from_attributes=True)

    class PersonCreate(PersonBase):
        pass

    class PersonRead(PersonBase):
        full_name: str

        model_config = {"from_attributes": True}

    app = FastAPI()

    @app.post("/people/", response_model=PersonRead)
    def create_person(person: PersonCreate) -> Any:
        db_person = Person.model_validate(person)
        return db_person

    client = TestClient(app)

    person_data = {"name": "Dive", "lastname": "Wilson"}
    response = client.post("/people/", json=person_data)
    data = response.json()
    assert response.status_code == 200, response.text
    assert data["name"] == person_data["name"]
    assert data["lastname"] == person_data["lastname"]
    assert data["full_name"] == person_data["name"] + " " + person_data["lastname"]

Domain

Subdomains

Calls

Frequently Asked Questions

What does test_read_with_orm_mode() do?
test_read_with_orm_mode() is a function in the fastapi codebase, defined in tests/test_read_with_orm_mode.py.
Where is test_read_with_orm_mode() defined?
test_read_with_orm_mode() is defined in tests/test_read_with_orm_mode.py at line 8.
What does test_read_with_orm_mode() call?
test_read_with_orm_mode() calls 1 function(s): full_name.

Analyze Your Own Codebase

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

Try Supermodel Free