Implemented Ad-Hoc Task handling
This commit is contained in:
@@ -30,7 +30,10 @@ from consistency_check import (
|
||||
_git_pull,
|
||||
_patch_task_status_in_file,
|
||||
_report_needs_action,
|
||||
archive_closed_workplans,
|
||||
canonical_workplan_filename,
|
||||
get_tasks_from_workplan,
|
||||
iter_workplan_files,
|
||||
normalise_workstream_status,
|
||||
parse_frontmatter,
|
||||
parse_task_blocks,
|
||||
@@ -168,6 +171,63 @@ class TestGetTasksFromWorkplan:
|
||||
tasks = get_tasks_from_workplan(meta, body)
|
||||
assert tasks == []
|
||||
|
||||
|
||||
class TestArchivedWorkplans:
|
||||
def test_canonical_workplan_filename_strips_archive_date_prefix(self):
|
||||
assert canonical_workplan_filename(Path("260501-CUST-WP-0001-demo.md")) == "CUST-WP-0001-demo.md"
|
||||
assert canonical_workplan_filename(Path("CUST-WP-0001-demo.md")) == "CUST-WP-0001-demo.md"
|
||||
|
||||
def test_iter_workplan_files_includes_archived_directory(self, tmp_path):
|
||||
workplans = tmp_path / "workplans"
|
||||
archived = workplans / "archived"
|
||||
archived.mkdir(parents=True)
|
||||
active_file = workplans / "CUST-WP-0001-active.md"
|
||||
archived_file = archived / "260501-CUST-WP-0000-old.md"
|
||||
active_file.write_text("---\nid: CUST-WP-0001\n---\n", encoding="utf-8")
|
||||
archived_file.write_text("---\nid: CUST-WP-0000\n---\n", encoding="utf-8")
|
||||
|
||||
assert iter_workplan_files(workplans) == [active_file, archived_file]
|
||||
|
||||
def test_archive_closed_workplans_moves_done_file_with_date_prefix(self, tmp_path):
|
||||
repo = tmp_path / "repo"
|
||||
workplans = repo / "workplans"
|
||||
workplans.mkdir(parents=True)
|
||||
wp = workplans / "CUST-WP-0001-demo.md"
|
||||
wp.write_text(
|
||||
"---\n"
|
||||
"id: CUST-WP-0001\n"
|
||||
"type: workplan\n"
|
||||
"title: Demo\n"
|
||||
"domain: custodian\n"
|
||||
"status: done\n"
|
||||
"owner: codex\n"
|
||||
"created: \"2026-05-01\"\n"
|
||||
"---\n"
|
||||
"```task\nid: CUST-WP-0001-T01\nstatus: done\npriority: medium\n```\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
moved = archive_closed_workplans(str(repo), completion_date="260501")
|
||||
|
||||
assert moved == ["workplans/CUST-WP-0001-demo.md -> workplans/archived/260501-CUST-WP-0001-demo.md"]
|
||||
assert not wp.exists()
|
||||
assert (workplans / "archived" / "260501-CUST-WP-0001-demo.md").exists()
|
||||
|
||||
def test_archive_closed_workplans_leaves_open_tasks_in_place(self, tmp_path):
|
||||
repo = tmp_path / "repo"
|
||||
workplans = repo / "workplans"
|
||||
workplans.mkdir(parents=True)
|
||||
wp = workplans / "CUST-WP-0001-demo.md"
|
||||
wp.write_text(
|
||||
"---\nid: CUST-WP-0001\ntype: workplan\ntitle: Demo\ndomain: custodian\n"
|
||||
"status: done\nowner: codex\ncreated: \"2026-05-01\"\n---\n"
|
||||
"```task\nid: CUST-WP-0001-T01\nstatus: todo\npriority: medium\n```\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
assert archive_closed_workplans(str(repo), completion_date="260501") == []
|
||||
assert wp.exists()
|
||||
|
||||
def test_ignores_non_list_frontmatter_tasks(self):
|
||||
meta = {"tasks": "not-a-list"}
|
||||
body = "# No blocks\n"
|
||||
|
||||
Reference in New Issue
Block a user