Harden coding retro resolver selection

This commit is contained in:
2026-06-18 15:13:08 +02:00
parent 206bb336d2
commit 23e2316dff
3 changed files with 148 additions and 4 deletions

View File

@@ -215,6 +215,29 @@ def test_coding_retro_returns_latest_progress_suggestions(monkeypatch) -> None:
],
},
},
{
"id": "newer-30-day-retro",
"event_type": "coding_retro",
"summary": "monthly coding retro ready",
"created_at": "2026-06-07T17:15:00Z",
"detail": {
"generated_at": "2026-06-07T17:14:30Z",
"window": {
"days": 30,
"since": "2026-05-08T00:00:00Z",
"until": "2026-06-07T00:00:00Z",
},
"suggestions": [
{
"repo": "broad-retro-repo",
"title": "Should not displace the weekly retro",
"recommendation": "Keep weekly schedule bounded.",
"priority": "high",
"score": 99,
}
],
},
},
])
monkeypatch.setenv("STATE_HUB_URL", "http://state-hub.test/")
@@ -229,7 +252,7 @@ def test_coding_retro_returns_latest_progress_suggestions(monkeypatch) -> None:
assert calls == [
{
"url": "http://state-hub.test/progress/",
"params": {"limit": 20},
"params": {"event_type": "coding_retro", "limit": 20},
"timeout": 10.0,
}
]
@@ -251,6 +274,47 @@ def test_coding_retro_returns_latest_progress_suggestions(monkeypatch) -> None:
]
def test_coding_retro_returns_empty_when_window_does_not_match(monkeypatch) -> None:
def fake_get(url: str, **kwargs: Any) -> DummyResponse:
return DummyResponse([
{
"id": "monthly-retro",
"event_type": "coding_retro",
"summary": "monthly coding retro ready",
"created_at": "2026-06-07T17:10:00Z",
"detail": {
"window": {"days": 30},
"suggestions": [
{
"repo": "activity-core",
"title": "Broad retro item",
"recommendation": "Do not emit from weekly schedule.",
"priority": "high",
"score": 10,
}
],
},
}
])
monkeypatch.setattr(httpx, "get", fake_get)
result = StateHubContextResolver().resolve(
"coding_retro",
None,
{"event_type": "coding_retro", "window_days": 7},
)
assert result == {
"suggestions": [],
"window": None,
"generated_at": None,
"source_progress_id": None,
"event_type": "coding_retro",
"summary": "",
}
def test_coding_retro_returns_empty_shape_when_not_published(monkeypatch) -> None:
def fake_get(url: str, **kwargs: Any) -> DummyResponse:
return DummyResponse([