- #6 Config tab by serial: the empty legacy edit form stays hidden (settings are read-only until phase 5); the settings box shows from the start, 'Not read yet', and a different unit's settings are never left on screen. - #10 A start/stop that went out but was not confirmed is no longer called 'failed'. The route now adds 'sent' (acknowledged / unknown) and 'audit_id' to a ChangeUnconfirmed -- same status, same message -- and the page says 'Start monitoring not confirmed: <what happened, audit record>'. - #12 Device tab by serial: the empty legacy Compliance/Project tables are hidden behind a pointer to the Config tab; a Micromate's Firmware card reads 'Thor line (version not read)' (its version string is in 0x01, undecoded). - #16 A 504 with nothing sent adds: the connection opened, so the modem is reachable -- another program (THOR or Blastware) may be holding the line, or the unit is busy. Measured 2026-10-29: THOR polling leaves SFM a 0-byte 504. New logic lives in sfm/static/device_routing.js (firmwareLabel, deviceErrorText, changeErrorText, serialPanes) under Node tests; the page glue in sfm_webapp.js only applies them. Checked in jsdom against the real page (served at a fake origin, /static from disk): all four, legacy mode unchanged, no script errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
2b886c4f39
commit
8123d75d72
7 files changed
+163
-22
No files matched your search
@@ -2,6 +2,8 @@
|
||||
FastAPI Query() defaults are FieldInfo objects, not values."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -418,10 +420,13 @@ def test_a_change_unconfirmed_keeps_its_cause_status_and_names_the_audit_record(
|
||||
"failed: silent -- audit record c7", audit_id="c7", sent="acknowledged",
|
||||
http_status=504)
|
||||
monkeypatch.setattr(srv, "_device_access_instance", Raises())
|
||||
with pytest.raises(HTTPException) as e:
|
||||
srv.device_monitor_start(**CH)
|
||||
assert e.value.status_code == 504
|
||||
assert "audit record c7" in e.value.detail
|
||||
resp = srv.device_monitor_start(**CH)
|
||||
assert resp.status_code == 504 # the cause's status, unchanged
|
||||
body = json.loads(resp.body)
|
||||
assert "audit record c7" in body["detail"]
|
||||
# #10 (2026-11-02): the page tells "may have been sent" from "nothing sent" by
|
||||
# these, not by matching the message.
|
||||
assert (body["sent"], body["audit_id"]) == ("acknowledged", "c7")
|
||||
|
||||
|
||||
def test_device_commands_normalises_the_serial(tmp_path, monkeypatch):
|
||||
|
||||
@@ -28,7 +28,7 @@ NODE = shutil.which("node")
|
||||
pytestmark = pytest.mark.skipif(NODE is None, reason="node is not installed; the page-logic tests need it")
|
||||
|
||||
EXPORTS = ["seriesFromSerial", "unitQuery", "deviceUrl", "confirmedSeries", "controlsFor", "eventView", "settingsRows", "perIndexLive", "escapeHtml",
|
||||
"changeSummary", "downloadSummary"]
|
||||
"changeSummary", "downloadSummary", "firmwareLabel", "deviceErrorText", "changeErrorText", "serialPanes"]
|
||||
|
||||
|
||||
def _block() -> str:
|
||||
@@ -234,3 +234,59 @@ def test_the_per_index_routes_follow_the_list_not_the_keyboard():
|
||||
def test_escape_html_makes_a_unit_string_inert():
|
||||
r = run(["escapeHtml", ['Bench <b id="x">&\'']], ["escapeHtml", [None]], ["escapeHtml", [42]])
|
||||
assert r == ["Bench <b id="x">&'", "", "42"]
|
||||
|
||||
|
||||
|
||||
# ── Batch 2 (1c bench polish, 2026-11-02) ─────────────────────────────────────
|
||||
|
||||
def test_firmware_label_says_which_line_a_micromate_runs():
|
||||
# #12: a Micromate's version string is in 0x01, undecoded; its firmware line is known.
|
||||
r = run(["firmwareLabel", [{"firmware": "S338.17"}]], ["firmwareLabel", [{"firmware_version": "S338.17"}]],
|
||||
["firmwareLabel", [{"firmware": None, "detail": {"firmware_line": "thor"}}]],
|
||||
["firmwareLabel", [{"firmware": None, "detail": {"firmware_line": "blastware"}}]],
|
||||
["firmwareLabel", [{"firmware": None, "detail": {"firmware_line": "unknown"}}]],
|
||||
["firmwareLabel", [{}]], ["firmwareLabel", [None]])
|
||||
assert r == ["S338.17", "S338.17", "Thor line (version not read)", "Blastware line (version not read)",
|
||||
"—", "—", "—"]
|
||||
|
||||
|
||||
HINT = ("the connection opened, so the modem is reachable — another program (THOR or Blastware) may be "
|
||||
"holding this unit's line, or the unit is busy (e.g. its sensor check)")
|
||||
|
||||
|
||||
def test_a_504_says_another_program_may_hold_the_line():
|
||||
# #16: measured 2026-10-29 -- while THOR polls a Micromate, SFM's connection is
|
||||
# accepted and gets 0 bytes, a 504. The hint is not added once a change was sent.
|
||||
silent = {"detail": "the unit did not answer: no reply"}
|
||||
sent = {"detail": "start monitoring was sent and acknowledged, but reading the state back failed: x "
|
||||
"-- audit record c7", "sent": "acknowledged", "audit_id": "c7"}
|
||||
r = run(["deviceErrorText", [504, silent, S4, "HTTP 504"]], ["deviceErrorText", [504, sent, S4, "HTTP 504"]],
|
||||
["deviceErrorText", [503, {"detail": "could not connect: refused"}, S4, "HTTP 503"]],
|
||||
["deviceErrorText", [504, silent, {"serial": "UM20147", "host": "", "tcpPort": 9034}, "HTTP 504"]],
|
||||
["deviceErrorText", [502, {}, S4, "HTTP 502"]])
|
||||
assert r == [f"the unit did not answer: no reply — {HINT}", sent["detail"], "could not connect: refused",
|
||||
"the unit did not answer: no reply", "HTTP 502"]
|
||||
|
||||
|
||||
def test_a_change_that_was_sent_is_not_called_failed():
|
||||
# #10: a ChangeUnconfirmed body carries `sent`; anything else is a real failure.
|
||||
sent = {"detail": "start monitoring was sent and acknowledged, but reading the state back failed: x "
|
||||
"-- audit record c7", "sent": "acknowledged", "audit_id": "c7"}
|
||||
r = run(["changeErrorText", ["Start", 504, sent, S3, "HTTP 504"]],
|
||||
["changeErrorText", ["Stop", 503, {**sent, "sent": "unknown"}, S3, "HTTP 503"]],
|
||||
["changeErrorText", ["Start", 504, {"detail": "the unit did not answer: no reply"}, S3, "HTTP 504"]],
|
||||
["changeErrorText", ["Stop", 409, {"detail": "not BE9441: BE12599 answered"}, S3, "HTTP 409"]])
|
||||
assert r[0] == f"Start monitoring not confirmed: {sent['detail']}"
|
||||
assert r[1] == f"Stop monitoring not confirmed: {sent['detail']}"
|
||||
assert r[2] == f"Start monitoring failed: the unit did not answer: no reply — {HINT}"
|
||||
assert r[3] == "Stop monitoring failed: not BE9441: BE12599 answered"
|
||||
assert not any(x.startswith(("Start monitoring failed", "Stop monitoring failed")) for x in r[:2])
|
||||
|
||||
|
||||
def test_serial_mode_hides_the_legacy_forms():
|
||||
# #6 / #12: by serial, settings are read-only until phase 5 -- no empty edit
|
||||
# form, no empty legacy tables; the settings box shows from the start.
|
||||
r = run(["serialPanes", [True, False]], ["serialPanes", [True, True]], ["serialPanes", [False, False]])
|
||||
assert r == [{"configForm": False, "settingsBox": True, "settingsPlaceholder": True, "legacyDeviceTables": False},
|
||||
{"configForm": False, "settingsBox": True, "settingsPlaceholder": False, "legacyDeviceTables": False},
|
||||
{"configForm": True, "settingsBox": False, "settingsPlaceholder": False, "legacyDeviceTables": True}]
|
||||
Reference in new issue
Block a user