feat(n7web): enhance control workflows and status feedback
This commit is contained in:
@@ -451,7 +451,7 @@ def test_mode_provider_failure_degrades_to_unknown_instead_of_empty(
|
||||
assert "0 个" not in answer.answer
|
||||
|
||||
|
||||
def test_learned_peripheral_requires_enabled_capability_and_matching_nfc_card(
|
||||
def test_learned_peripheral_requires_enabled_capability_and_durable_nfc_binding(
|
||||
vehicle_service: SeatDemoService,
|
||||
) -> None:
|
||||
capability = {
|
||||
@@ -470,8 +470,8 @@ def test_learned_peripheral_requires_enabled_capability_and_matching_nfc_card(
|
||||
absent_item = absent["learned_peripherals"][0]
|
||||
assert absent_item["enabled"] is True
|
||||
assert absent_item["active_for_current_nfc_card"] is False
|
||||
assert absent_item["assistant_callable"] is False
|
||||
assert "闪灯玩具" not in _catalog(
|
||||
assert absent_item["assistant_callable"] is True
|
||||
assert "闪灯玩具" in _catalog(
|
||||
vehicle_service, peripherals=lambda: [capability]
|
||||
).control_terms(absent)
|
||||
|
||||
@@ -910,6 +910,39 @@ def test_provider_failure_is_not_misreported_as_an_empty_catalog(
|
||||
assert "没有" not in answer.answer
|
||||
|
||||
|
||||
def test_nfc_reader_failure_does_not_hide_durable_peripheral_bindings(
|
||||
vehicle_service: SeatDemoService,
|
||||
) -> None:
|
||||
capability = {
|
||||
"id": "lamp-on",
|
||||
"status": "learned",
|
||||
"enabled": True,
|
||||
"device_id": "lamp-1",
|
||||
"device_name": "闪灯玩具",
|
||||
"object_names": ["闪灯玩具"],
|
||||
"action": "开启",
|
||||
"action_names": ["打开"],
|
||||
"card_uid": "A1B2",
|
||||
"slot": 1,
|
||||
}
|
||||
|
||||
def nfc_unavailable() -> dict[str, object]:
|
||||
raise RuntimeError("reader offline")
|
||||
|
||||
catalog = _catalog(
|
||||
vehicle_service,
|
||||
peripherals=lambda: [capability],
|
||||
nfc=nfc_unavailable,
|
||||
)
|
||||
snapshot = catalog.snapshot()
|
||||
item = snapshot["learned_peripherals"][0]
|
||||
|
||||
assert snapshot["source_status"]["learned_peripherals"] == "ready"
|
||||
assert item["active_for_current_nfc_card"] is False
|
||||
assert item["assistant_callable"] is True
|
||||
assert "闪灯玩具" in catalog.control_terms(snapshot)
|
||||
|
||||
|
||||
def test_catalog_revision_is_stable_and_changes_with_live_capabilities(
|
||||
vehicle_service: SeatDemoService,
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user