MCPcopy
hub / github.com/pallets-eco/flask-sqlalchemy / test_first_or_404

Function test_first_or_404

tests/test_view_query.py:25–32  ·  view source on GitHub ↗
(db: SQLAlchemy, Todo: t.Any)

Source from the content-addressed store, hash-verified

23
24@pytest.mark.usefixtures("app_ctx")
25def test_first_or_404(db: SQLAlchemy, Todo: t.Any) -> None:
26 db.session.add(Todo(title="a"))
27 db.session.commit()
28 result = db.first_or_404(db.select(Todo).filter_by(title="a"))
29 assert result.title == "a"
30
31 with pytest.raises(NotFound):
32 db.first_or_404(db.select(Todo).filter_by(title="b"))
33
34
35@pytest.mark.usefixtures("app_ctx")

Callers

nothing calls this directly

Calls 2

TodoClass · 0.70
first_or_404Method · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…