Never touch spools of printers this bridge never ran

A fresh instance (empty data volume, no printers configured yet) treated
every spool whose "drucker" field named a printer as stale and moved it to
storage. Now only spools at our slot locations or naming a printer this
bridge runs or has written are corrected; written printer names are kept
in the state (seeded from the applied locations on update).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014GcEk5tkfFSYD6NTF66NkC
This commit is contained in:
Jonas MenzelandClaude Opus 5.5 committed 2026-10-25 20:32:51 +01:00
1 parent 60d583e66e
commit c04964066f
4 files changed
+35 -2

No files matched your search

+19
View File
@@ -417,6 +417,7 @@ def test_stale_printer_locations_go_to_storage(env):
env["sm"].add(3, location="Lager", extra={"drucker": '"Links"', "slot": "1"})
env["sm"].add(4, location="Regal 1")
env["bridge"].state.data["written_locations"] = ["CC2 Slot 2"]
env["bridge"].state.data["written_printers"] = ["Links"] # a printer this bridge used to run
poll(env)
assert env["sm"].db[1]["location"] == "Lager"
assert env["sm"].db[2]["location"] == "Lager"
@@ -773,3 +774,21 @@ def test_job_progress_only_read_while_printing(env):
job = b.snapshot["printers"][0]["job"]
assert job["file"] == "cube.gcode" and job["grams"] == 1.23 and job["slots"] == [{"slot": 1, "grams": 1.23}]
assert job["progress"] == 40 and job["layer"] == 12 and job["layers"] == 30 and job["remaining"] == 600
def test_fresh_bridge_leaves_other_bridges_spools_alone(env):
"""A new instance (empty data volume, no printers yet) must not pull spools out of printers it never ran."""
env["settings"].save({"printers": []})
env["sm"].add(11, location="CC2 Links Slot 4", extra={"drucker": '"CC2 Links"', "slot": "4"})
env["sm"].add(1, location="CC2 Rechts Slot 2", extra={"drucker": '"CC2 Rechts"', "slot": "2"})
poll(env, 13)
assert env["sm"].db[11]["location"] == "CC2 Links Slot 4" and env["sm"].extra(11)["drucker"] == "CC2 Links"
assert env["sm"].db[1]["location"] == "CC2 Rechts Slot 2"
assert not [c for c in env["sm"].calls if c[0] in ("location", "extra")]
def test_printer_names_written_are_remembered(env):
env["sm"].add(5)
insert(env, 0, 5)
poll(env)
assert env["bridge"].state.data["written_printers"] == ["Rechts"]