Files
praxis/tests/test_debrief_persistence.py
T
Praxis CI fbd6602814 docs(milestone): complete v0.1 foundation
---ci---
phase: 0
milestone: v0.1
status: complete
---/ci---
2026-08-01 13:32:48 +00:00

50 lines
1.4 KiB
Python

"""Test for debrief persistence migration (TASK-05-05)."""
from __future__ import annotations
import asyncio
import sqlite3
from pathlib import Path
import pytest
from db.migrate import apply_migrations
from db.store import PraxisStore, HARDCODED_LEARNER_ID
def test_migration_0002_debrief_applies(tmp_db: Path):
"""Both migrations apply cleanly; the debrief_text column exists."""
applied = apply_migrations(tmp_db)
assert "0001_init" in applied
assert "0002_debrief" in applied
conn = sqlite3.connect(str(tmp_db))
cols = {
r[1]
for r in conn.execute("PRAGMA table_info(sessions)").fetchall()
}
conn.close()
assert "debrief_text" in cols
def test_debrief_text_persisted(tmp_db: Path):
"""TASK-05-05: after a session, SELECT debrief_text returns the debrief."""
store = PraxisStore(tmp_db)
async def _run():
await store.init()
sid = await store.start_session(HARDCODED_LEARNER_ID, "cs_refund_ca_v01")
await store.end_session(
sid,
branch_path=["accept_resolution"],
outcome="success",
cost_cents=5,
debrief_text="You acknowledged the customer well. Improve your speed. Next: practice empathy-first.",
)
sess = await store.get_session(sid)
return sess
sess = asyncio.run(_run())
assert sess is not None
assert "acknowledged" in sess.debrief_text
assert "empathy" in sess.debrief_text