Files
grotti/tests/test_filament_pause.py
T

78 lines
2.5 KiB
Python

"""Filament-Pause-Heuristik aus ACE/mmu und Meldungen."""
import unittest
from grotti.moonraker import filament_out_hint
class FilamentOutHintTests(unittest.TestCase):
def test_message_10107(self):
code, text = filament_out_hint({}, "Report code 10107")
self.assertEqual(code, "message")
self.assertIn("10107", text)
def test_reason_for_pause(self):
code, text = filament_out_hint({"reason_for_pause": "Filament runout"}, "")
self.assertEqual(code, "reason")
self.assertIn("runout", text.lower())
def test_active_filament_empty_needs_active_tool(self):
code, text = filament_out_hint({
"tool": 1,
"gate_status": [1, 1, 1, 1],
"active_filament": {"empty": True},
})
self.assertEqual(code, "active_empty")
self.assertIn("leer", text.lower())
def test_anycubic_empty_without_tool_is_not_runout(self):
# Live A2/Kobra 3: empty=true, tool=-1, alle gate_status 0 — auch beim Druck
code, text = filament_out_hint({
"tool": -1,
"gate": -1,
"is_paused": False,
"gate_status": [0, 0, 0, 0],
"active_filament": {"empty": True, "material": ""},
"reason_for_pause": "",
})
self.assertIsNone(code)
self.assertIsNone(text)
def test_manual_pause_anycubic_not_material(self):
code, text = filament_out_hint({
"tool": -1,
"is_paused": True,
"gate_status": [0, 0, 0, 0],
"active_filament": {"empty": True},
}, "paused")
self.assertIsNone(code)
self.assertIsNone(text)
def test_gate_status_zero_for_tool(self):
code, text = filament_out_hint({
"tool": 2,
"gate_status": [1, 1, 0, 1],
"active_filament": {"type": "PLA"},
})
self.assertEqual(code, "gate_empty")
self.assertIn("3", text)
def test_all_gates_zero_not_empty_signal(self):
# Anycubic: gate_status oft durchgängig 0 — kein Runout-Beweis
code, text = filament_out_hint({
"tool": 0,
"gate_status": [0, 0, 0, 0],
"active_filament": {"type": "PLA", "empty": False},
})
self.assertIsNone(code)
self.assertIsNone(text)
def test_no_hint_for_plain_pause(self):
code, text = filament_out_hint({"tool": 0, "gate_status": [1, 1]}, "paused")
self.assertIsNone(code)
self.assertIsNone(text)
if __name__ == "__main__":
unittest.main()