Files
siftlode/backend/tests/test_db_lane.py
T
peter b1832afd18 style: apply ruff format across backend + scripts (line-length 100)
Mechanical, whole-tree `ruff format` pass — no behaviour change. Recorded in
.git-blame-ignore-revs (next commit) so git blame skips it.
2026-08-23 07:43:06 +02:00

23 lines
840 B
Python

"""Smoke test proving the DB-backed lane works (R6 S3b): a real commit round-trips, and each
test starts from a clean database (TRUNCATE isolation), which is what lets the transaction-
ownership tests (R6 S2) trust what they commit."""
from sqlalchemy import func, select
from app.models import User
def test_commit_roundtrips(db):
db.add(User(email="lane@example.com", role="admin"))
db.commit()
got = db.execute(select(User).where(User.email == "lane@example.com")).scalar_one()
assert got.id is not None
assert got.role == "admin"
assert got.is_active is True # server_default applied on flush/commit
def test_isolation_starts_clean(db):
# If the previous test's committed row leaked, this count would be 1 — TRUNCATE must reset it.
assert db.scalar(select(func.count()).select_from(User)) == 0