"""Smoke test proving the DB-backed lane works: a real commit round-trips, and each test starts from a clean database (TRUNCATE isolation), which is what lets the transaction- ownership tests 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