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