update
This commit is contained in:
@@ -356,6 +356,52 @@ operations:
|
||||
[{"name": "transmittance_pct", "value": 20}],
|
||||
)
|
||||
|
||||
def test_session_overlay_ignores_stale_repository_user_modes(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory) / "profiles"
|
||||
session_root = Path(directory) / "session"
|
||||
stale = root / "vehicles" / "denza_n7" / "user" / "stale.yaml"
|
||||
stale.parent.mkdir(parents=True)
|
||||
stale.write_text(
|
||||
"""
|
||||
id: stale
|
||||
name: 上次运行模式
|
||||
scope:
|
||||
vehicle_ids: [denza_n7]
|
||||
operations:
|
||||
- domain: roof
|
||||
capability: roof.set_transmittance
|
||||
target_scope: vehicle
|
||||
parameters:
|
||||
transmittance_pct: 20
|
||||
""".strip() + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
registry = ModeProfileRegistry(root, user_root=session_root)
|
||||
|
||||
self.assertEqual(registry.public_modes("denza_n7"), [])
|
||||
created = registry.save_mode(
|
||||
"本次运行模式",
|
||||
[
|
||||
{
|
||||
"domain": "roof",
|
||||
"capability": "roof.set_transmittance",
|
||||
"target_scope": "vehicle",
|
||||
"parameters": {"transmittance_pct": 35},
|
||||
}
|
||||
],
|
||||
vehicle_id="denza_n7",
|
||||
)
|
||||
self.assertTrue(Path(created.source).is_relative_to(session_root))
|
||||
self.assertEqual(
|
||||
{mode["id"] for mode in registry.public_modes("denza_n7")},
|
||||
{created.id},
|
||||
)
|
||||
|
||||
registry.delete_user_mode(created.id, "denza_n7")
|
||||
self.assertFalse(Path(created.source).exists())
|
||||
self.assertEqual(registry.public_modes("denza_n7"), [])
|
||||
|
||||
def test_delete_user_mode_removes_yaml_and_protects_presets(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def source(name: str) -> str:
|
||||
return (ROOT / "apps" / "web-console" / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_calibration_twin_tracks_labels_and_commits_direct_axis_drag() -> None:
|
||||
calibration = source("self-calibration.js")
|
||||
seat3d = source("self-repair-seat3d.js")
|
||||
styles = source("self-calibration.css")
|
||||
|
||||
assert 'data-seat-axis-label="backrest"' in calibration
|
||||
assert 'data-seat-label-line="legrest"' in calibration
|
||||
assert 'window.addEventListener("calibration-seat-axis-preview"' in calibration
|
||||
assert 'window.addEventListener("calibration-seat-axis-commit"' in calibration
|
||||
assert "function layoutSeatLabels()" in seat3d
|
||||
assert "makePanel(legrestPivot, cushionShape(0.08)" in seat3d
|
||||
assert "function legrestShape(" not in seat3d
|
||||
assert 'enableAxisDrag: true' in seat3d
|
||||
assert 'function startAxisDrag(axis, event, source = "model")' in seat3d
|
||||
assert 'startAxisDrag(item.axis, event, "label")' in seat3d
|
||||
assert "calculateAxisDragVector(axis, value)" in seat3d
|
||||
assert "Math.max(0, Math.min(100," in seat3d
|
||||
assert 'new CustomEvent("calibration-seat-axis-commit"' in seat3d
|
||||
assert ".v2-calibration-label-lines line" in styles
|
||||
assert '.v2-axis-tag[data-control-enabled="true"]' in styles
|
||||
assert "pointer-events: auto;" in styles
|
||||
|
||||
|
||||
def test_extension_pet_and_transient_vehicle_state_restart_contract() -> None:
|
||||
extension = source("self-extension.js")
|
||||
styles = source("self-extension.css")
|
||||
|
||||
assert 'id="extensionDesktopPet"' in extension
|
||||
assert "function initializeDesktopPet()" in extension
|
||||
assert "saved.vehicleExecutions = {};" in extension
|
||||
assert "saved.lastProtocol = null;" in extension
|
||||
assert ".v2-extension-pet-body" in styles
|
||||
assert "@keyframes extension-pet-blink" in styles
|
||||
|
||||
|
||||
def test_virtual_modules_reset_but_physical_sessions_remain_authoritative() -> None:
|
||||
orchestration = source("app.js")
|
||||
calibration = source("self-calibration.js")
|
||||
repair = source("self-repair.js")
|
||||
|
||||
assert 'sessionStorage.removeItem("cognitive-agent.conversation-id")' in orchestration
|
||||
assert 'api("/session/reset")' in calibration
|
||||
assert 'if (state.transport?.mode === "simulation")' in calibration
|
||||
assert 'if (backendMode === "bench")' in repair
|
||||
assert 'await apiPost("/runtime/reset-statistics")' in repair
|
||||
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from cognitive_agent.application.calibration import protocol
|
||||
from cognitive_agent.application.calibration.service import CalibrationService
|
||||
from cognitive_agent.application.calibration.service import ApiError, CalibrationService
|
||||
|
||||
|
||||
def test_protocol_matches_android_golden_vectors() -> None:
|
||||
@@ -89,3 +89,30 @@ def test_simulation_uses_real_wire_boundary_and_generates_pose() -> None:
|
||||
assert not stopped["controller"]["armed"]
|
||||
finally:
|
||||
service.close()
|
||||
|
||||
|
||||
def test_virtual_session_restart_resets_axes_without_touching_hardware() -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
service = CalibrationService(Path(directory))
|
||||
service.start()
|
||||
try:
|
||||
service.connect_can({"mode": "simulation"})
|
||||
service.move(1, 720)
|
||||
time.sleep(0.15)
|
||||
|
||||
reset = service.reset_virtual_session()
|
||||
|
||||
assert reset["transport"]["mode"] == "simulation"
|
||||
assert reset["transport"]["state"] == "disconnected"
|
||||
assert reset["controller"]["armed"] is False
|
||||
assert [axis["permille"] for axis in reset["axes"]] == [0, 0, 0, 0]
|
||||
assert reset["operation"]["phase"] == protocol.PHASE_IDLE
|
||||
finally:
|
||||
service.close()
|
||||
|
||||
|
||||
def test_virtual_session_restart_rejects_real_bench_state() -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
service = CalibrationService(Path(directory))
|
||||
with pytest.raises(ApiError, match="真实台架会话"):
|
||||
service.reset_virtual_session()
|
||||
|
||||
Reference in New Issue
Block a user