Home / File/ test_tutorial010.py — fastapi Source File

test_tutorial010.py — fastapi Source File

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

File python FastAPI Applications 6 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  946e7769_9306_de18_7f88_3c96c9905fd7["test_tutorial010.py"]
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  946e7769_9306_de18_7f88_3c96c9905fd7 --> 0dda2280_3359_8460_301c_e98c77e78185
  d1bf66df_8a92_7a7c_dab4_0865060effa4["unittest.mock"]
  946e7769_9306_de18_7f88_3c96c9905fd7 --> d1bf66df_8a92_7a7c_dab4_0865060effa4
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  946e7769_9306_de18_7f88_3c96c9905fd7 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  a7c04dee_ee23_5891_b185_47ff6bed036d["testclient.py"]
  946e7769_9306_de18_7f88_3c96c9905fd7 --> a7c04dee_ee23_5891_b185_47ff6bed036d
  6cfacb3b_8c48_2f4e_4b08_ce243e5897ec["tutorial010_py39.py"]
  946e7769_9306_de18_7f88_3c96c9905fd7 --> 6cfacb3b_8c48_2f4e_4b08_ce243e5897ec
  92d5148b_c551_4971_6d5b_49107cd74239["get_db"]
  946e7769_9306_de18_7f88_3c96c9905fd7 --> 92d5148b_c551_4971_6d5b_49107cd74239
  style 946e7769_9306_de18_7f88_3c96c9905fd7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Annotated, Any
from unittest.mock import Mock, patch

from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient

from docs_src.dependencies.tutorial010_py39 import get_db


def test_get_db():
    app = FastAPI()

    @app.get("/")
    def read_root(c: Annotated[Any, Depends(get_db)]):
        return {"c": str(c)}

    client = TestClient(app)

    dbsession_mock = Mock()

    with patch(
        "docs_src.dependencies.tutorial010_py39.DBSession",
        return_value=dbsession_mock,
        create=True,
    ):
        response = client.get("/")

    assert response.status_code == 200
    assert response.json() == {"c": str(dbsession_mock)}

Domain

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does test_tutorial010.py do?
test_tutorial010.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_tutorial010.py?
test_tutorial010.py defines 1 function(s): test_get_db.
What does test_tutorial010.py depend on?
test_tutorial010.py imports 6 module(s): __init__.py, get_db, testclient.py, tutorial010_py39.py, typing, unittest.mock.
Where is test_tutorial010.py in the architecture?
test_tutorial010.py is located at tests/test_tutorial/test_dependencies/test_tutorial010.py (domain: FastAPI, subdomain: Applications, directory: tests/test_tutorial/test_dependencies).

Analyze Your Own Codebase

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

Try Supermodel Free