Files
rdb-discovery/tests/test_status.py
T
robbond 21611b7c4e feat(TASK-005): wire project state and agent handoff into start/complete commands
- Add update_project_state() helper: updates Current Task + Last Updated
  in PROJECT_STATE.md via regex sub, preserving all surrounding formatting.
- Add update_agent_handoff() helper: updates Current Stage + Current Task
  sections in AGENT_HANDOFF.md, auto-detected from project_stage().
- Wire both helpers into rdb start TASK-ID and rdb complete TASK-ID CLI
  commands so task lifecycle transitions propagate to all control files.
- ADDING test_status.py with 5 tests: update_project_state task/timestamp
  updates, missing-file false return, agent handoff update and miss.

Acceptance criteria met:
- rdb start/complete now update PROJECT_STATE.md
- rdb start/complete now update AGENT_HANDOFF.md
- RUN_LOG.md already updated (pre-existing)
- Task formatting preserved (regex sub targets single line only)
2026-06-02 10:37:38 +01:00

57 lines
1.9 KiB
Python

from pathlib import Path
from rdb_discovery.status import (
update_project_state,
update_agent_handoff,
)
def test_update_project_state_updates_task_id(tmp_path: Path) -> None:
ps = tmp_path / "PROJECT_STATE.md"
ps.write_text(
"# Project State\n\nCurrent Stage: DISCOVERY\nPrevious Stage: NONE\nNext Stage: BOOTSTRAP_READY\n\nCurrent Task: None\nActive Branch: main\n\nLast Updated: 2026-01-01\n",
encoding="utf-8",
)
assert update_project_state(tmp_path, "TASK-005") is True
content = ps.read_text(encoding="utf-8")
assert "Current Task: TASK-005" in content
def test_update_project_state_updates_timestamp(tmp_path: Path) -> None:
ps = tmp_path / "PROJECT_STATE.md"
ps.write_text(
"# Project State\n\nCurrent Stage: DISCOVERY\nPrevious Stage: NONE\nNext Stage: BOOTSTRAP_READY\n\nCurrent Task: None\nActive Branch: main\n\nLast Updated: 2026-01-01\n",
encoding="utf-8",
)
assert update_project_state(tmp_path, "TASK-999") is True
content = ps.read_text(encoding="utf-8")
from datetime import date
expected_date = date.today().isoformat()
assert f"Last Updated: {expected_date}" in content
def test_update_project_state_no_file_returns_false(tmp_path: Path) -> None:
assert update_project_state(tmp_path, "TASK-001") is False
def test_update_agent_handoff_updates_task_and_stage(tmp_path: Path) -> None:
ah = tmp_path / "AGENT_HANDOFF.md"
ah.write_text(
"# Agent Handoff\n\n## Current Stage\n\nDISCOVERY\n\n## Current Task\n\nNone\n\n## Instructions For Agent\n\n- Complete one task only\n",
encoding="utf-8",
)
assert update_agent_handoff(tmp_path, "TASK-005") is True
content = ah.read_text(encoding="utf-8")
assert "Current Task" in content
assert "TASK-005" in content
def test_update_agent_handoff_no_file_returns_false(tmp_path: Path) -> None:
assert update_agent_handoff(tmp_path, "TASK-001") is False