kin: auto-commit after pipeline

This commit is contained in:
Gros Frumos 2026-03-17 16:37:42 +02:00
parent 9bd5c22cb5
commit c3314b9125

View file

@ -399,3 +399,50 @@ def test_check_parent_alive_process_lookup_error_aborts(conn):
task = models.get_task(conn, "VDOL-001")
assert task["status"] == "blocked"
assert str(dead_ppid) in (task.get("blocked_reason") or "")
# ---------------------------------------------------------------------------
# KIN-OBS-019: регрессионные тесты через inspect.getsource() — decision #367
# ---------------------------------------------------------------------------
def test_watchdog_source_has_no_sqlite3_connect():
"""Регрессия: watchdog не должен содержать прямой вызов sqlite3.connect() (decision #367)."""
import core.watchdog as wd
source = inspect.getsource(wd)
assert "sqlite3.connect" not in source, (
"REGRESSION: core/watchdog.py содержит sqlite3.connect() — "
"должен использовать get_connection() из core.db"
)
def test_watchdog_source_has_no_explicit_process_lookup_error():
"""Регрессия: watchdog не должен явно упоминать ProcessLookupError (decision #357).
Обработка мёртвых процессов унифицирована через OSError + errno.ESRCH.
"""
import core.watchdog as wd
source = inspect.getsource(wd)
assert "ProcessLookupError" not in source, (
"REGRESSION: core/watchdog.py явно использует ProcessLookupError — "
"должен использовать OSError + errno.ESRCH"
)
def test_check_dead_pipelines_kill_succeeds_no_change(tmp_path):
"""os.kill успешно (нет исключения) → процесс жив, статус задачи не меняется."""
fake_pid = 54323
db_path, task_id, pipeline_id = _db_with_running_pipeline(tmp_path, fake_pid)
# os.kill returns None (no exception) — process is alive
with patch("core.watchdog.os.kill", return_value=None):
_check_dead_pipelines(db_path)
conn = init_db(db_path=str(db_path))
task = models.get_task(conn, task_id)
pipeline_row = conn.execute(
"SELECT status FROM pipelines WHERE id=?", (pipeline_id,)
).fetchone()
conn.close()
assert task["status"] != "blocked"
assert pipeline_row["status"] == "running"