92 lines
3.0 KiB
Python
92 lines
3.0 KiB
Python
"""store.print_queue_out und Hilfen ohne Datenbank."""
|
|
|
|
import unittest
|
|
from datetime import datetime, timezone
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from grotti.store import print_queue_out
|
|
|
|
|
|
class PrintQueueOutTests(unittest.TestCase):
|
|
def test_basic_fields(self):
|
|
now = datetime(2026, 10, 14, 12, 0, tzinfo=timezone.utc)
|
|
out = print_queue_out(
|
|
{
|
|
"id": 7,
|
|
"file_id": 3,
|
|
"filename": "teil.gcode",
|
|
"host": "10.10.1.10",
|
|
"printer_name": "A2",
|
|
"family": "kobra_3",
|
|
"priority": 50,
|
|
"status": "waiting",
|
|
"spool_id": None,
|
|
"ace_map": [{"paint_index": 0, "ams_index": 1}],
|
|
"bed_leveling": True,
|
|
"override_machine": False,
|
|
"message": "wartet",
|
|
"steps": [],
|
|
"step_index": 0,
|
|
"repeat_total": 1,
|
|
"repeat_done": 0,
|
|
"phase": "",
|
|
"phase_started_at": None,
|
|
"created_at": now,
|
|
"updated_at": now,
|
|
}
|
|
)
|
|
self.assertEqual(out["id"], 7)
|
|
self.assertEqual(out["host"], "10.10.1.10")
|
|
self.assertEqual(out["family_label"], "Kobra 3")
|
|
self.assertTrue(out["bed_leveling"])
|
|
self.assertEqual(out["ace_map"][0]["ams_index"], 1)
|
|
self.assertFalse(out["is_ablauf"])
|
|
self.assertEqual(out["filename"], "teil.gcode")
|
|
|
|
def test_ablauf_labels_skip_legacy_mesh(self):
|
|
steps = [
|
|
{"type": "print"},
|
|
{"type": "cool"},
|
|
{"type": "sweep"},
|
|
{"type": "check", "probe_count": 3, "mesh_min_x": 0},
|
|
{"type": "check", "max_delta_mm": 1},
|
|
]
|
|
out = print_queue_out(
|
|
{
|
|
"id": 1,
|
|
"file_id": 1,
|
|
"filename": "x.gcode",
|
|
"host": "h",
|
|
"printer_name": "",
|
|
"family": "kobra_3",
|
|
"priority": 100,
|
|
"status": "running",
|
|
"spool_id": None,
|
|
"ace_map": [],
|
|
"bed_leveling": False,
|
|
"override_machine": False,
|
|
"message": "",
|
|
"steps": steps,
|
|
"step_index": 2,
|
|
"repeat_total": 2,
|
|
"repeat_done": 0,
|
|
"phase": "cooling",
|
|
"phase_started_at": None,
|
|
"created_at": None,
|
|
"updated_at": None,
|
|
}
|
|
)
|
|
self.assertTrue(out["is_ablauf"])
|
|
self.assertNotIn("mesh", " ".join(out["step_labels"]).lower())
|
|
self.assertEqual(out["step_labels"][0], "Drucken")
|
|
self.assertIn(out["step_label_current"], out["step_labels"])
|
|
self.assertEqual(out["repeat_total"], 2)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|