feat(viewer): unify spatial clipping, planning and observation surfaces
Share spatial clipping and height slices across live planning and recorded observations. Refine scene navigation, report serialization and viewer presentation.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Periodic planning reports must not serialize/compress on the ASGI loop."""
|
||||
import json
|
||||
import threading
|
||||
from types import SimpleNamespace
|
||||
|
||||
@@ -14,22 +15,19 @@ from k1link.web.response_compression import ResponseCompressionMiddleware
|
||||
def test_active_report_keeps_content_and_encodes_off_loop(monkeypatch, encoding):
|
||||
document = {"state": "completed", "evidence": [{"label": "Проверка", "x": 1.25}] * 50}
|
||||
calls = []
|
||||
original_json = planning_live_api.JSONResponse
|
||||
original_compress = planning_live_api.gzip.compress
|
||||
|
||||
class RecordedJSON(original_json):
|
||||
def render(self, content):
|
||||
calls.append(("json", threading.get_ident()))
|
||||
return super().render(content)
|
||||
def encoded():
|
||||
calls.append(("json", threading.get_ident()))
|
||||
return json.dumps(document).encode()
|
||||
|
||||
def compress(*args, **kwargs):
|
||||
calls.append(("gzip", threading.get_ident()))
|
||||
return original_compress(*args, **kwargs)
|
||||
|
||||
monkeypatch.setattr(planning_live_api, "JSONResponse", RecordedJSON)
|
||||
monkeypatch.setattr(planning_live_api.gzip, "compress", compress)
|
||||
app = FastAPI()
|
||||
app.include_router(planning_live_api.build_planning_live_router(SimpleNamespace(get=lambda: document)))
|
||||
app.include_router(planning_live_api.build_planning_live_router(SimpleNamespace(get_json=encoded)))
|
||||
app.add_middleware(ResponseCompressionMiddleware)
|
||||
|
||||
@app.get("/loop-thread")
|
||||
@@ -38,7 +36,8 @@ def test_active_report_keeps_content_and_encodes_off_loop(monkeypatch, encoding)
|
||||
|
||||
with TestClient(app) as client:
|
||||
loop_id = client.get("/loop-thread").json()
|
||||
result = client.get("/api/v1/mission-planner/live-tests/active", headers={"Accept-Encoding": encoding})
|
||||
result = client.get("/api/v1/mission-planner/live-tests/active",
|
||||
headers={"Accept-Encoding": encoding})
|
||||
assert result.status_code == 200
|
||||
assert result.json() == document # Includes HTTP decompression; no double gzip.
|
||||
assert result.headers["cache-control"] == "no-store"
|
||||
@@ -53,7 +52,7 @@ def test_active_report_keeps_content_and_encodes_off_loop(monkeypatch, encoding)
|
||||
|
||||
|
||||
def test_active_report_retains_empty_and_failure_contract():
|
||||
service = SimpleNamespace(get=lambda: None)
|
||||
service = SimpleNamespace(get_json=lambda: b"null")
|
||||
app = FastAPI()
|
||||
app.include_router(planning_live_api.build_planning_live_router(service))
|
||||
with TestClient(app) as client:
|
||||
@@ -63,7 +62,7 @@ def test_active_report_retains_empty_and_failure_contract():
|
||||
def fail():
|
||||
raise RuntimeError("synthetic unavailable report")
|
||||
|
||||
service.get = fail
|
||||
service.get_json = fail
|
||||
result = client.get("/api/v1/mission-planner/live-tests/active")
|
||||
assert result.status_code == 409
|
||||
assert result.json() == {"detail": "synthetic unavailable report"}
|
||||
|
||||
Reference in New Issue
Block a user