fix(tools/kanban): sync kanban_unblock response status with DB state
This commit is contained in:
parent
296494db0e
commit
9a7a43b5d6
2 changed files with 37 additions and 2 deletions
|
|
@ -1328,6 +1328,40 @@ def test_unblock_happy_path(monkeypatch, worker_env):
|
|||
conn.close()
|
||||
|
||||
|
||||
def test_unblock_with_pending_parents_returns_todo(monkeypatch, tmp_path):
|
||||
monkeypatch.delenv("HERMES_KANBAN_TASK", raising=False)
|
||||
home = tmp_path / ".hermes"
|
||||
home.mkdir()
|
||||
monkeypatch.setenv("HERMES_HOME", str(home))
|
||||
monkeypatch.setenv("HERMES_PROFILE", "orchestrator")
|
||||
from pathlib import Path as _Path
|
||||
monkeypatch.setattr(_Path, "home", lambda: tmp_path)
|
||||
|
||||
from hermes_cli import kanban_db as kb
|
||||
kb._INITIALIZED_PATHS.clear()
|
||||
kb.init_db()
|
||||
conn = kb.connect()
|
||||
try:
|
||||
parent = kb.create_task(conn, title="parent", assignee="worker")
|
||||
child = kb.create_task(conn, title="child", assignee="worker", parents=[parent])
|
||||
conn.execute("UPDATE tasks SET status='blocked' WHERE id=?", (child,))
|
||||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
from tools import kanban_tools as kt
|
||||
out = kt._handle_unblock({"task_id": child})
|
||||
d = json.loads(out)
|
||||
assert d["ok"] is True
|
||||
assert d["status"] == "todo"
|
||||
|
||||
conn = kb.connect()
|
||||
try:
|
||||
assert kb.get_task(conn, child).status == "todo"
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def test_unblock_rejects_non_blocked_task(monkeypatch, worker_env):
|
||||
monkeypatch.delenv("HERMES_KANBAN_TASK", raising=False)
|
||||
from tools import kanban_tools as kt
|
||||
|
|
|
|||
|
|
@ -1276,7 +1276,7 @@ def _maybe_auto_subscribe(conn: Any, task_id: str) -> bool:
|
|||
|
||||
|
||||
def _handle_unblock(args: dict, **kw) -> str:
|
||||
"""Transition a blocked task back to ready."""
|
||||
"""Transition a blocked task back to its actual post-unblock status."""
|
||||
guard = _require_orchestrator_tool("kanban_unblock")
|
||||
if guard:
|
||||
return guard
|
||||
|
|
@ -1293,7 +1293,8 @@ def _handle_unblock(args: dict, **kw) -> str:
|
|||
ok = kb.unblock_task(conn, str(tid))
|
||||
if not ok:
|
||||
return tool_error(f"could not unblock {tid} (not blocked or unknown)")
|
||||
return _ok(task_id=str(tid), status="ready")
|
||||
task = kb.get_task(conn, str(tid))
|
||||
return _ok(task_id=str(tid), status=task.status if task else None)
|
||||
finally:
|
||||
conn.close()
|
||||
except ValueError as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue