78 lines
2.5 KiB
Python
78 lines
2.5 KiB
Python
from pathlib import Path
|
|
|
|
from scripts.timmy_config_pr_backlog_audit import extract_issue_refs, summarize_backlog
|
|
|
|
|
|
def test_extract_issue_refs_from_title_body_and_branch() -> None:
|
|
text = "feat: crisis response — manipulation & edge cases 500 pairs (#598)"
|
|
body = "Refs #1471 and closes #598"
|
|
head = "fix/598-crisis-manipulation"
|
|
|
|
refs = extract_issue_refs(text, body, head)
|
|
|
|
assert 598 in refs
|
|
assert 1471 in refs
|
|
|
|
|
|
def test_summarize_backlog_finds_duplicates_missing_reviewers_and_stale_prs() -> None:
|
|
backlog = [
|
|
{
|
|
"number": 765,
|
|
"title": "feat: crisis response (#598)",
|
|
"body": "Closes #598",
|
|
"head": "fix/598-crisis-manipulation",
|
|
"mergeable": True,
|
|
"review_count": 0,
|
|
"requested_reviewers": 0,
|
|
"updated_at": "2026-04-01T00:00:00Z",
|
|
},
|
|
{
|
|
"number": 766,
|
|
"title": "feat: edge cases (#598)",
|
|
"body": "Closes #598",
|
|
"head": "fix/598",
|
|
"mergeable": True,
|
|
"review_count": 1,
|
|
"requested_reviewers": 0,
|
|
"updated_at": "2026-04-15T00:00:00Z",
|
|
},
|
|
{
|
|
"number": 777,
|
|
"title": "feat: token budget tracker (#622)",
|
|
"body": "Closes #622",
|
|
"head": "fix/622-token-tracker",
|
|
"mergeable": False,
|
|
"review_count": 0,
|
|
"requested_reviewers": 0,
|
|
"updated_at": "2026-04-15T00:00:00Z",
|
|
},
|
|
]
|
|
|
|
summary = summarize_backlog(backlog, now_iso="2026-04-16T00:00:00Z")
|
|
|
|
assert summary["total_open_prs"] == 3
|
|
assert summary["mergeable_count"] == 2
|
|
assert summary["missing_reviewer_count"] == 2
|
|
assert summary["stale_count"] == 1
|
|
assert summary["duplicate_issue_groups"][0]["issue_refs"] == [598]
|
|
assert {pr["number"] for pr in summary["duplicate_issue_groups"][0]["prs"]} == {765, 766}
|
|
|
|
|
|
def test_timmy_config_pr_backlog_report_exists_with_required_sections() -> None:
|
|
report = Path("reports/2026-04-16-timmy-config-pr-backlog-audit.md")
|
|
text = report.read_text(encoding="utf-8")
|
|
|
|
required = [
|
|
"# Timmy-config PR Backlog Audit — the-nexus #1471",
|
|
"## Source Snapshot",
|
|
"## Live Summary",
|
|
"## Issue Body Drift",
|
|
"## Duplicate Issue Groups",
|
|
"## Reviewer Coverage",
|
|
"## Mergeable Snapshot",
|
|
"## Stale PRs",
|
|
"## Recommended Next Actions",
|
|
]
|
|
missing = [item for item in required if item not in text]
|
|
assert not missing, missing
|