from pathlib import Path from backend.session_store import SessionStore def test_session_store_creates_isolated_session_dirs(tmp_path: Path) -> None: store = SessionStore(root=tmp_path, ttl_seconds=60) first = store.ensure_session("session-a") second = store.ensure_session("session-b") assert first.session_id == "session-a" assert second.session_id == "session-b" assert first.root.exists() assert second.root.exists() assert first.root != second.root def test_session_store_prunes_expired_sessions(tmp_path: Path) -> None: store = SessionStore(root=tmp_path, ttl_seconds=0) session = store.ensure_session("session-a") marker = session.root / "marker.txt" marker.write_text("old", encoding="utf-8") removed = store.cleanup_expired(now=store._now() + 1) assert removed == ["session-a"] assert not session.root.exists()