Home / Function/ test_get_db() — fastapi Function Reference

test_get_db() — fastapi Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  f0e81b69_4a04_2af8_307f_bb254bf1d35c["test_get_db()"]
  946e7769_9306_de18_7f88_3c96c9905fd7["test_tutorial010.py"]
  f0e81b69_4a04_2af8_307f_bb254bf1d35c -->|defined in| 946e7769_9306_de18_7f88_3c96c9905fd7
  style f0e81b69_4a04_2af8_307f_bb254bf1d35c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tests/test_tutorial/test_dependencies/test_tutorial010.py lines 10–29

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

Frequently Asked Questions

What does test_get_db() do?
test_get_db() is a function in the fastapi codebase, defined in tests/test_tutorial/test_dependencies/test_tutorial010.py.
Where is test_get_db() defined?
test_get_db() is defined in tests/test_tutorial/test_dependencies/test_tutorial010.py at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free