mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-30 11:23:49 +08:00
fixes
This commit is contained in:
@@ -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"]
|
||||
Reference in New Issue
Block a user