rack:单板页 Hub 行与拓扑图、单路操作拆成 RailOps;开机按键改 5 s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
这个提交包含在:
@@ -218,3 +218,23 @@ def test_flash_mode_extend_round_trip(env):
|
||||
ev = {e["seq"]: e for e in c.get("/api/events", params={"board": B}).json()}
|
||||
assert "加钟 30 分钟" in ev[9101]["name"]
|
||||
assert "断电自动退出" in ev[9102]["name"] # 0.1.13:254 带 0x80 位,不能被当成「加钟 126 分钟」
|
||||
|
||||
|
||||
def test_hub_round_trip_and_event_names(env):
|
||||
# 固件 0.1.14:hub 命令经 /cmd 放行、回应带 hub 对象;事件 22 按 arg 命名、mV 列不当电压显示
|
||||
c, hub, sim, db = env
|
||||
post = lambda body: c.post("/api/boards/%s/cmd" % B, json=body).json()
|
||||
r = post({"cmd": "hub", "mode": "on"})
|
||||
assert r["ok"] is True and r["hub"]["mode"] == "on" and r["hub"]["on"] is True
|
||||
r = post({"cmd": "hub", "mode": "auto", "min": 0})
|
||||
assert r["hub"]["on"] is False and r["hub"]["why"] == "off"
|
||||
assert post({"cmd": "status"})["hub"]["mode"] == "auto"
|
||||
assert c.post("/api/boards/%s/cmd" % B, json={"cmd": "hub", "min": 999}).status_code == 400
|
||||
now = 10 ** 13
|
||||
db.many("INSERT INTO events (board_id, seq, t_ms, rail, type, arg, mv, ua, received) VALUES (?,?,?,?,?,?,?,?,?)",
|
||||
[(B, 9201, 1, 0, 22, 1, 2, 0, now), (B, 9202, 2, 0, 22, 0, 0, 0, now),
|
||||
(B, 9203, 3, 0, 22, 0x11, 7, 0, now)])
|
||||
ev = {e["seq"]: e for e in c.get("/api/events", params={"board": B}).json()}
|
||||
assert "唤醒:有手机开着 VBUS" in ev[9201]["name"] and ev[9201]["mv"] is None
|
||||
assert "休眠" in ev[9202]["name"] and ev[9202]["severe"] is False
|
||||
assert "模式改为常开" in ev[9203]["name"]
|
||||
|
||||
@@ -320,6 +320,19 @@ def test_flash_mode_command_and_event_numbers():
|
||||
protocol.build_command(bad)
|
||||
|
||||
|
||||
def test_hub_command_and_event_numbers():
|
||||
# 固件 0.1.14:命令 15 / 事件 22(cmd.h / evlog.h 冻结编号)
|
||||
assert protocol.CMD_NAMES[15] == "hub" and protocol.EVENT_TYPES[22][0] == "HUB"
|
||||
assert protocol.HUB_MODES == ("auto", "on") and protocol.HUB_WHY_NAMES[2] == "有手机开着 VBUS"
|
||||
assert protocol.build_command({"cmd": "hub", "mode": "on"}) == {"cmd": "hub", "mode": "on"}
|
||||
assert protocol.build_command({"cmd": "hub", "min": 0}) == {"cmd": "hub", "min": 0}
|
||||
assert protocol.build_command({"cmd": "hub", "mode": "auto", "min": 30}) == {"cmd": "hub", "mode": "auto", "min": 30}
|
||||
for bad in ({"cmd": "hub"}, {"cmd": "hub", "mode": "off"}, {"cmd": "hub", "min": 241},
|
||||
{"cmd": "hub", "min": -1}, {"cmd": "hub", "min": True}):
|
||||
with pytest.raises(protocol.CmdError):
|
||||
protocol.build_command(bad)
|
||||
|
||||
|
||||
def test_flash_mode_extend_command():
|
||||
assert protocol.build_command({"cmd": "flash_mode", "rail": 1, "add": 30}) == {"cmd": "flash_mode", "rail": 1, "add": 30}
|
||||
for bad in ({"cmd": "flash_mode", "rail": 1, "add": 0},
|
||||
|
||||
在新工单中引用
屏蔽一个用户