Grotti 3.6.1: Abgebrochene Läufe bleiben im Protokoll, Spulenwechsel bucht den laufenden Druck nicht vorzeitig ab, und der Pi öffnet große Dateien nicht mehr parallel.

This commit is contained in:
Dominic Gundel committed 2026-11-01 18:56:14 +01:00
1 parent 2b1e36634a
commit 5081212212
23 files changed
+559 -65

No files matched your search

+63
View File
@@ -137,6 +137,69 @@ class WatcherOfflineTests(unittest.TestCase):
kinds = [call.args[3] for call in emit.call_args_list]
self.assertEqual(kinds, ["abbruch", "offline", "start"])
def test_other_file_without_offline_releases_the_old_run(self):
live = {
"host": HOST,
"name": "Kobra S1",
"state": "printing",
"ok": True,
"filename": "andere.gcode",
"weight": 0,
}
old = {"id": 42, "filename": FILE}
new = {"id": 99, "filename": "andere.gcode"}
seen = {"n": 0}
def live_run(_conn, _host, filename=""):
seen["n"] += 1
if seen["n"] <= 3:
return old
return None
with mock.patch.object(self.watcher, "_emit") as emit, \
mock.patch.object(self.watcher, "_track_print", return_value=new), \
mock.patch.object(self.watcher, "_ensure_start_segment"), \
mock.patch.object(self.watcher, "_check_spool", return_value=False), \
mock.patch("grotti.watcher.store.find_live_run", side_effect=live_run), \
mock.patch("grotti.watcher.store.abandon_live_runs") as abandon, \
mock.patch("grotti.watcher.jobs.sync_history") as sync:
self.watcher._one(mock.Mock(), live)
sync.assert_called_once()
abandon.assert_called()
self.assertIn("abbruch", [call.args[3] for call in emit.call_args_list])
self.assertIn("start", [call.args[3] for call in emit.call_args_list])
def test_cancel_event_survives_deleted_live_run(self):
self.watcher._cancel_hits[HOST] = 2
live = {
"host": HOST,
"name": "Kobra S1",
"state": "cancelled",
"ok": True,
"filename": FILE,
}
dangling = {"id": 42, "filename": FILE, "state": "in_progress"}
def row(_conn, run_id):
if run_id == 77:
return {"id": 77, "filename": FILE}
return None
with mock.patch("grotti.watcher.store.find_live_run", side_effect=[dangling, None]), \
mock.patch("grotti.watcher.store.find_open_history_run", return_value=None), \
mock.patch("grotti.watcher.store.get_run_row", side_effect=row), \
mock.patch("grotti.watcher.store.latest_run_id", return_value=77), \
mock.patch("grotti.watcher.store.abandon_live_runs"), \
mock.patch("grotti.watcher.store.set_bed_needs_clear"), \
mock.patch("grotti.watcher.store.set_printer_active_run"), \
mock.patch("grotti.watcher.jobs.sync_history") as sync, \
mock.patch("grotti.watcher.notify.record") as record:
self.watcher._one(mock.Mock(), live)
sync.assert_called_once()
record.assert_called()
self.assertEqual(record.call_args.kwargs["run_id"], 77)
self.assertEqual(record.call_args.args[4], "abbruch")
if __name__ == "__main__":
unittest.main()