oclaw/tests/test_session_delete_cascade.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

22 lines
947 B
Python

from __future__ import annotations
from svc.persistence.sqlite_store import SqliteStore
def test_delete_session_cascades_chat_message_and_tool_log(tmp_path) -> None: # noqa: ANN001
db = tmp_path / "ops.sqlite"
store = SqliteStore(str(db))
sess = store.create_session("t")
store.add_message(session_id=sess.id, role="user", content="hi", event_type="user_text")
store.add_tool_log(session_id=sess.id, tool_name="x", args={"a": 1}, result={"ok": True})
store.delete_session(sess.id)
with store._connect() as conn: # noqa: SLF001
c1 = conn.execute("select count(1) from chat_message where session_id=?", (sess.id,)).fetchone()[0]
c2 = conn.execute("select count(1) from tool_log where session_id=?", (sess.id,)).fetchone()[0]
c3 = conn.execute("select count(1) from chat_session where id=?", (sess.id,)).fetchone()[0]
assert int(c3) == 0
assert int(c1) == 0
assert int(c2) == 0