feat(map): adopt DC Default scene
This commit is contained in:
+19
-1
@@ -13,6 +13,7 @@ from fastapi.routing import APIRoute
|
||||
|
||||
from k1link.web.map_api import (
|
||||
MAP_GATEWAY_URL_ENV,
|
||||
MAP_SANDBOX_HIDE_CREDITS_ENV,
|
||||
MapGatewayConfiguration,
|
||||
MapGatewayProxy,
|
||||
build_map_router,
|
||||
@@ -108,7 +109,10 @@ def test_configuration_is_fail_closed_and_rejects_non_origin_values(
|
||||
MapGatewayConfiguration.from_environment()
|
||||
|
||||
|
||||
def test_runtime_config_exposes_only_same_origin_contract_and_hides_internal_origin() -> None:
|
||||
def test_runtime_config_exposes_only_same_origin_contract_and_hides_internal_origin(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
monkeypatch.delenv(MAP_SANDBOX_HIDE_CREDITS_ENV, raising=False)
|
||||
service, requests = _service(
|
||||
lambda request: httpx.Response(
|
||||
200,
|
||||
@@ -133,11 +137,25 @@ def test_runtime_config_exposes_only_same_origin_contract_and_hides_internal_ori
|
||||
"terrain": 1,
|
||||
"buildings": 96188,
|
||||
}
|
||||
assert document["sandbox"] == {"hide_credit_overlay": False}
|
||||
assert response.headers["cache-control"] == "no-store"
|
||||
assert not requests
|
||||
assert "map-gateway.internal" not in _response_body(response).decode()
|
||||
|
||||
|
||||
def test_runtime_config_hides_credits_only_with_explicit_sandbox_flag(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
service, _ = _service(lambda request: httpx.Response(200))
|
||||
monkeypatch.setenv(MAP_SANDBOX_HIDE_CREDITS_ENV, "true")
|
||||
|
||||
response = service.runtime_configuration()
|
||||
|
||||
assert isinstance(response, JSONResponse)
|
||||
document = json.loads(_response_body(response))
|
||||
assert document["sandbox"] == {"hide_credit_overlay": True}
|
||||
|
||||
|
||||
def test_runtime_config_is_fail_closed_when_gateway_is_not_configured() -> None:
|
||||
service = MapGatewayProxy(MapGatewayConfiguration(None))
|
||||
response = service.runtime_configuration()
|
||||
|
||||
@@ -15,15 +15,23 @@ from k1link.web.map_view_api import (
|
||||
)
|
||||
|
||||
|
||||
def test_default_map_view_is_honestly_unlocated_and_cache_safe() -> None:
|
||||
def test_default_map_view_matches_the_canonical_foundry_scene_and_cache_policy() -> None:
|
||||
document = default_map_view()
|
||||
|
||||
assert document.schema_version == "missioncore.map-view/v1"
|
||||
assert document.schema_version == "missioncore.map-view/v2"
|
||||
assert document.revision == 0
|
||||
assert document.view.camera is None
|
||||
assert document.view.camera is not None
|
||||
assert document.view.camera.longitude == pytest.approx(37.618423)
|
||||
assert document.view.camera.latitude == pytest.approx(55.751244)
|
||||
assert document.view.camera.height == pytest.approx(40_000.0)
|
||||
assert document.view.selected_subject_id is None
|
||||
assert document.view.layer_visibility.imagery is True
|
||||
assert document.view.layer_visibility.grid is True
|
||||
assert document.view.layer_visibility.targets is True
|
||||
assert document.view.visual_settings.imagery_saturation == 0
|
||||
assert document.view.visual_settings.imagery_alpha == 27
|
||||
assert document.view.visual_settings.imagery_gamma == 57
|
||||
assert document.view.visual_settings.background_color == "#08090d"
|
||||
assert document.view.cache_intent.enabled is True
|
||||
assert document.view.cache_intent.no_overwrite is True
|
||||
|
||||
@@ -98,3 +106,47 @@ def test_persisted_document_contains_no_runtime_or_credential_material(
|
||||
assert "gateway" not in serialized
|
||||
assert "provider" not in serialized
|
||||
assert "cesium" not in serialized
|
||||
|
||||
|
||||
def test_v1_map_view_is_upgraded_without_rewriting_the_source_file(
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
store = MapViewStore(tmp_path / "map-view")
|
||||
store.root.mkdir(parents=True)
|
||||
legacy = {
|
||||
"schema_version": "missioncore.map-view/v1",
|
||||
"revision": 7,
|
||||
"view": {
|
||||
"camera": None,
|
||||
"visual_settings": {
|
||||
"atmosphere_enabled": True,
|
||||
"lighting_enabled": False,
|
||||
"monochrome_enabled": True,
|
||||
"terrain_exaggeration": 2,
|
||||
"buildings_maximum_screen_space_error": 12,
|
||||
"camera_animation_enabled": False,
|
||||
},
|
||||
"map_height": 720,
|
||||
"inspector_open_sections": [],
|
||||
"cache_intent": {"enabled": True, "no_overwrite": True},
|
||||
"selected_subject_id": None,
|
||||
"layer_visibility": {
|
||||
"imagery": True,
|
||||
"terrain": True,
|
||||
"buildings": True,
|
||||
"grid": False,
|
||||
"targets": True,
|
||||
},
|
||||
},
|
||||
}
|
||||
store.document_path.write_text(json.dumps(legacy), encoding="utf-8")
|
||||
|
||||
upgraded = store.read()
|
||||
|
||||
assert upgraded.schema_version == "missioncore.map-view/v2"
|
||||
assert upgraded.revision == 7
|
||||
assert upgraded.view.camera is None
|
||||
assert upgraded.view.visual_settings.atmosphere_enabled is True
|
||||
assert upgraded.view.visual_settings.sun_enabled is False
|
||||
assert upgraded.view.visual_settings.monochrome_enabled is True
|
||||
assert json.loads(store.document_path.read_text(encoding="utf-8")) == legacy
|
||||
|
||||
Reference in New Issue
Block a user