feat: add node coverage and improve investigation presentation
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
from datetime import datetime, timezone
|
||||
from uuid import uuid4
|
||||
|
||||
from app.domain.schemas.operational_task import TaskPresentationEventCommand
|
||||
from app.mcp.models import QueryResult
|
||||
from app.mcp.presentation_preview import saved_presentation_preview
|
||||
|
||||
|
||||
def test_abbreviated_coverage_keeps_publishable_command_without_copying_geometry():
|
||||
result = QueryResult(
|
||||
source="generate_node_coverage", source_ref="mcp:analysis", evidence_id="mcp:analysis",
|
||||
queried_at=datetime.now(timezone.utc), semantics="analysis", origin="system_data", truncated=False,
|
||||
data={"result": {"map_payload": {"type": "FeatureCollection", "features": [{"large": "geometry"}]},
|
||||
"coverage": {"status": "partial", "groups": {"isolation": {
|
||||
"node_ids": ["A", "B"], "mapped_node_count": 1, "missing_node_ids": ["B"],
|
||||
}}}}},
|
||||
)
|
||||
hint = saved_presentation_preview(result)
|
||||
assert hint == saved_presentation_preview(result)
|
||||
assert hint["groups"]["isolation"] == {"node_count": 2, "mapped_node_count": 1, "missing_node_count": 1}
|
||||
command = TaskPresentationEventCommand(
|
||||
request_id=uuid4(), run_id=uuid4(), source_session_id="session", command=hint["command"],
|
||||
)
|
||||
assert command.command.evidence_id == result.evidence_id and command.command.data is None
|
||||
assert "geometry" not in str(hint["groups"]) and result.data["result"]["map_payload"]["features"]
|
||||
result.evidence_id = None
|
||||
assert saved_presentation_preview(result) is None
|
||||
|
||||
|
||||
def test_missing_geometry_does_not_offer_a_broken_overlay_command():
|
||||
result = QueryResult(
|
||||
source="generate_node_coverage", source_ref="mcp:analysis", evidence_id="mcp:analysis",
|
||||
queried_at=datetime.now(timezone.utc), semantics="analysis", origin="system_data", truncated=False,
|
||||
data={"result": {"coverage": {"status": "unavailable"}}},
|
||||
)
|
||||
assert saved_presentation_preview(result) is None
|
||||
Reference in New Issue
Block a user