22 lines
656 B
Python
22 lines
656 B
Python
"""Tests for structured session logging."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
|
|
from tai.session_log import SessionLogger
|
|
|
|
|
|
def test_session_logger_writes_jsonl_row(tmp_path) -> None: # type: ignore[no-untyped-def]
|
|
log_path = tmp_path / "logs" / "session.jsonl"
|
|
logger = SessionLogger.create(str(log_path))
|
|
|
|
logger.log_event("analysis_response", {"response": "Root cause is X"})
|
|
|
|
lines = log_path.read_text(encoding="utf-8").splitlines()
|
|
assert len(lines) == 1
|
|
|
|
row = json.loads(lines[0])
|
|
assert row["event"] == "analysis_response"
|
|
assert row["payload"]["response"] == "Root cause is X"
|
|
assert "ts" in row |