2026-07-08 16:35:37 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
import mcp_server.server as server
|
|
|
|
|
|
|
|
|
|
|
2026-07-08 22:34:56 +02:00
|
|
|
def test_normalize_progress_body_prefers_workplan_id_only() -> None:
|
|
|
|
|
body = server._normalize_progress_body({
|
|
|
|
|
"workplan_id": "wp-1",
|
|
|
|
|
"workstream_id": "wp-1",
|
|
|
|
|
"event_type": "note",
|
|
|
|
|
"summary": "test",
|
|
|
|
|
})
|
|
|
|
|
assert body == {
|
|
|
|
|
"workplan_id": "wp-1",
|
|
|
|
|
"event_type": "note",
|
|
|
|
|
"summary": "test",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
legacy_only = server._normalize_progress_body({
|
|
|
|
|
"workstream_id": "wp-legacy",
|
|
|
|
|
"event_type": "note",
|
|
|
|
|
"summary": "legacy",
|
|
|
|
|
})
|
|
|
|
|
assert legacy_only["workplan_id"] == "wp-legacy"
|
|
|
|
|
assert "workstream_id" not in legacy_only
|
|
|
|
|
|
|
|
|
|
|
2026-07-08 16:35:37 +02:00
|
|
|
def _fake_get(path: str, params: dict | None = None):
|
|
|
|
|
if path == "/topics":
|
|
|
|
|
return [{"id": "topic-1", "domain_slug": "infotech", "title": "Infotech"}]
|
|
|
|
|
if path == "/state/summary":
|
|
|
|
|
return {
|
2026-07-08 20:33:53 +02:00
|
|
|
"open_workplans": [
|
2026-07-08 16:35:37 +02:00
|
|
|
{
|
|
|
|
|
"id": "wp-1",
|
|
|
|
|
"topic_id": "topic-1",
|
|
|
|
|
"title": "Goalless",
|
|
|
|
|
"repo_id": "repo-1",
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
if path == "/decisions":
|
|
|
|
|
return []
|
|
|
|
|
if path == "/progress":
|
|
|
|
|
return []
|
|
|
|
|
if path == "/repos":
|
|
|
|
|
return [{"id": "repo-1", "slug": "demo-repo", "domain_slug": "infotech"}]
|
|
|
|
|
if path == "/repo-goals":
|
|
|
|
|
return [{"id": "goal-1", "title": "Ship it", "description": "d", "priority": "high"}]
|
|
|
|
|
if path == "/capability-catalog/":
|
|
|
|
|
return []
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_domain_summary_goal_guidance_is_workplan_first(monkeypatch) -> None:
|
|
|
|
|
monkeypatch.setattr(server, "_get", lambda path, params=None: _fake_get(path, params))
|
|
|
|
|
payload = json.loads(server.get_domain_summary("infotech"))
|
|
|
|
|
assert "workplans" in payload
|
|
|
|
|
assert payload["workstreams"] == payload["workplans"]
|
|
|
|
|
action = payload["goal_guidance"]["needs_workplan"][0]["action"]
|
|
|
|
|
assert "workplan" in action.lower()
|
|
|
|
|
assert "workstream is linked" not in action.lower()
|