This commit is contained in:
firestar5683
2026-07-06 22:32:54 -05:00
parent 33508d42ef
commit a08fe79cef
8 changed files with 190 additions and 7 deletions
@@ -73,7 +73,7 @@ def _save_status(params: Params, status):
history = []
status_copy["history"] = [str(line) for line in history if str(line).strip()][-120:]
status_copy["updatedAtSec"] = float(status_copy.get("updatedAtSec") or time.monotonic())
params.put_nonblocking(STATUS_PARAM, json.dumps(status_copy, separators=(",", ":")))
params.put_nonblocking(STATUS_PARAM, status_copy)
return status_copy
@@ -0,0 +1,22 @@
from openpilot.tools.lateral_maneuvers import lateral_maneuversd
class FakeParams:
def __init__(self):
self.writes = []
def put_nonblocking(self, key, value):
self.writes.append((key, value))
def test_save_status_writes_json_param_as_dict():
params = FakeParams()
saved = lateral_maneuversd._save_status(params, {
"state": "setup",
"history": ["", "Armed"],
})
assert params.writes == [(lateral_maneuversd.STATUS_PARAM, saved)]
assert isinstance(params.writes[0][1], dict)
assert saved["history"] == ["Armed"]