mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 19:12:07 +08:00
21 lines
892 B
Python
21 lines
892 B
Python
from types import SimpleNamespace
|
|
|
|
from openpilot.starpilot.common import starpilot_variables as spv
|
|
|
|
|
|
def test_get_starpilot_toggles_uses_last_non_empty_broadcast(monkeypatch):
|
|
params = SimpleNamespace(get_bool=lambda _key: False)
|
|
monkeypatch.setattr(spv.get_starpilot_toggles, "_params", params, raising=False)
|
|
monkeypatch.delattr(spv.get_starpilot_toggles, "_last_toggles_text", raising=False)
|
|
|
|
payload = '{"always_on_lateral": true, "vision_speed_limit_detection": true}'
|
|
sm_with_toggles = {"starpilotPlan": SimpleNamespace(starpilotToggles=payload)}
|
|
sm_without_toggles = {"starpilotPlan": SimpleNamespace(starpilotToggles="")}
|
|
|
|
first = spv.get_starpilot_toggles(sm_with_toggles)
|
|
second = spv.get_starpilot_toggles(sm_without_toggles)
|
|
|
|
assert first.always_on_lateral is True
|
|
assert second.always_on_lateral is True
|
|
assert second.vision_speed_limit_detection is True
|