Add todo_md_staleness State Hub context resolver
Supports daily TODO.md stale-review ActivityDefinition via GET /repos/todo-md-staleness.
This commit is contained in:
parent
20f8b2f31f
commit
00917696dd
2 changed files with 71 additions and 0 deletions
|
|
@ -192,6 +192,55 @@ def test_repo_sbom_status_bulk_returns_worst_repo(monkeypatch) -> None:
|
|||
assert by_slug["never-scanned"]["last_sbom_at"] is None
|
||||
|
||||
|
||||
def test_todo_md_staleness_returns_stale_repos(monkeypatch) -> None:
|
||||
calls: list[dict[str, Any]] = []
|
||||
|
||||
def fake_get(url: str, **kwargs: Any) -> DummyResponse:
|
||||
calls.append({"url": url, **kwargs})
|
||||
return DummyResponse({
|
||||
"stale_days": 6,
|
||||
"repos": [
|
||||
{
|
||||
"repo_slug": "markitect-main",
|
||||
"has_todo": True,
|
||||
"age_days": 12,
|
||||
"mtime": "2026-06-26T10:00:00+00:00",
|
||||
"todo_path": "/home/worsch/markitect-main/TODO.md",
|
||||
}
|
||||
],
|
||||
"stale_count": 1,
|
||||
"total_with_todo": 1,
|
||||
"total_scanned": 62,
|
||||
"worst_repo_slug": "markitect-main",
|
||||
"worst_age_days": 12,
|
||||
})
|
||||
|
||||
monkeypatch.setenv("STATE_HUB_URL", "http://state-hub.test")
|
||||
monkeypatch.setattr(httpx, "get", fake_get)
|
||||
|
||||
result = StateHubContextResolver().resolve(
|
||||
"todo_md_staleness", None, {"stale_days": 6}
|
||||
)
|
||||
|
||||
assert calls == [{
|
||||
"url": "http://state-hub.test/repos/todo-md-staleness",
|
||||
"params": {"stale_days": 6},
|
||||
"timeout": 10.0,
|
||||
}]
|
||||
assert result["stale_count"] == 1
|
||||
assert result["repos"][0]["repo_slug"] == "markitect-main"
|
||||
|
||||
|
||||
def test_todo_md_staleness_returns_empty_on_failure(monkeypatch) -> None:
|
||||
def fake_get(url: str, **kwargs: Any) -> DummyResponse:
|
||||
return DummyResponse(None, status_error=httpx.HTTPError("boom"))
|
||||
|
||||
monkeypatch.setenv("STATE_HUB_URL", "http://state-hub.test")
|
||||
monkeypatch.setattr(httpx, "get", fake_get)
|
||||
|
||||
assert StateHubContextResolver().resolve("todo_md_staleness", None, {}) == {}
|
||||
|
||||
|
||||
def test_repo_sbom_status_returns_empty_on_failure(monkeypatch) -> None:
|
||||
def fake_get(url: str, **kwargs: Any) -> DummyResponse:
|
||||
return DummyResponse(None, status_error=httpx.HTTPError("boom"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue