feat: complete dual-seat whole-vehicle orchestration

This commit is contained in:
vee
2026-08-12 15:12:40 +08:00
parent 32379a1573
commit 9ce64b3a01
62 changed files with 9741 additions and 3950 deletions
+53
View File
@@ -356,6 +356,59 @@ operations:
[{"name": "transmittance_pct", "value": 20}],
)
def test_delete_user_mode_removes_yaml_and_protects_presets(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
preset_path = root / "common" / "preset" / "office.yaml"
preset_path.parent.mkdir(parents=True)
preset_path.write_text(
"""
id: office
name: 办公模式
operations:
- domain: climate
capability: climate.set_temperature
target_scope: vehicle
parameters:
temperature_c: 24
""".strip()
+ "\n",
encoding="utf-8",
)
registry = ModeProfileRegistry(root)
user_profile = registry.save_mode(
"K歌模式",
[
{
"domain": "ambient_light",
"capability": "ambient_light.set_power",
"target_scope": "vehicle",
"parameters": {"state": "on"},
}
],
vehicle_id="denza_n7",
)
public_modes = {
mode["id"]: mode
for mode in registry.public_modes(vehicle_id="denza_n7")
}
self.assertEqual(public_modes[user_profile.id]["origin"], "user")
self.assertTrue(public_modes[user_profile.id]["deletable"])
self.assertEqual(public_modes["office"]["origin"], "preset")
self.assertFalse(public_modes["office"]["deletable"])
deleted = registry.delete_user_mode(user_profile.id, "denza_n7")
self.assertEqual(deleted.id, user_profile.id)
self.assertFalse(Path(user_profile.source).exists())
self.assertNotIn(
user_profile.id,
{mode["id"] for mode in registry.public_modes("denza_n7")},
)
with self.assertRaises(PermissionError):
registry.delete_user_mode("office", "denza_n7")
def test_update_mode_profile_backs_up_initial_yaml_and_restores(self) -> None:
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)