kin: KIN-BIZ-002 Исправить консистентность: approve через /tasks/{id}/approve не продвигает phase state machine
This commit is contained in:
parent
044bd15b2e
commit
39acc9cc4b
5 changed files with 288 additions and 4 deletions
|
|
@ -1267,6 +1267,83 @@ def test_kin016_pipeline_blocked_agent_stops_next_steps_integration(client):
|
|||
assert items[0]["agent_role"] == "debugger"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# KIN-BIZ-001 — telegram_sent из БД (не заглушка)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_kin_biz_001_telegram_sent_not_stub(client):
|
||||
"""Регрессия KIN-BIZ-001: /api/notifications возвращает реальный telegram_sent из БД, не False-заглушку."""
|
||||
from core.db import init_db
|
||||
from core import models
|
||||
conn = init_db(api_module.DB_PATH)
|
||||
models.update_task(
|
||||
conn, "P1-001",
|
||||
status="blocked",
|
||||
blocked_reason="cannot access repo",
|
||||
blocked_agent_role="debugger",
|
||||
)
|
||||
models.mark_telegram_sent(conn, "P1-001")
|
||||
conn.close()
|
||||
|
||||
r = client.get("/api/notifications")
|
||||
assert r.status_code == 200
|
||||
items = r.json()
|
||||
assert len(items) == 1
|
||||
# Ключевая проверка: telegram_sent должен быть True из БД, не False-заглушка
|
||||
assert items[0]["telegram_sent"] is True
|
||||
|
||||
|
||||
def test_kin_biz_001_notifications_telegram_sent_false_when_not_sent(client):
|
||||
"""KIN-BIZ-001: telegram_sent=False для задачи, где уведомление не отправлялось."""
|
||||
from core.db import init_db
|
||||
from core import models
|
||||
conn = init_db(api_module.DB_PATH)
|
||||
models.update_task(
|
||||
conn, "P1-001",
|
||||
status="blocked",
|
||||
blocked_reason="no access",
|
||||
blocked_agent_role="tester",
|
||||
)
|
||||
# Не вызываем mark_telegram_sent → telegram_sent остаётся 0
|
||||
conn.close()
|
||||
|
||||
r = client.get("/api/notifications")
|
||||
assert r.status_code == 200
|
||||
items = r.json()
|
||||
assert len(items) == 1
|
||||
assert items[0]["telegram_sent"] is False
|
||||
|
||||
|
||||
def test_kin_biz_001_telegram_sent_distinguishes_sent_and_not_sent(client):
|
||||
"""KIN-BIZ-001: список уведомлений корректно различает sent/not-sent задачи."""
|
||||
from core.db import init_db
|
||||
from core import models
|
||||
conn = init_db(api_module.DB_PATH)
|
||||
models.create_task(conn, "P1-002", "p1", "Another task")
|
||||
models.update_task(
|
||||
conn, "P1-001",
|
||||
status="blocked",
|
||||
blocked_reason="reason 1",
|
||||
blocked_agent_role="debugger",
|
||||
)
|
||||
models.update_task(
|
||||
conn, "P1-002",
|
||||
status="blocked",
|
||||
blocked_reason="reason 2",
|
||||
blocked_agent_role="tester",
|
||||
)
|
||||
# Telegram отправлен только для P1-001
|
||||
models.mark_telegram_sent(conn, "P1-001")
|
||||
conn.close()
|
||||
|
||||
r = client.get("/api/notifications")
|
||||
assert r.status_code == 200
|
||||
items = r.json()
|
||||
assert len(items) == 2
|
||||
by_id = {item["task_id"]: item for item in items}
|
||||
assert by_id["P1-001"]["telegram_sent"] is True
|
||||
assert by_id["P1-002"]["telegram_sent"] is False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# KIN-071: project_type и SSH-поля в API
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue