Grotti 2.5.1: Druckbericht, Statistik, Spulenakte und Protokoll-Fixes.
This commit is contained in:
1 parent
b277ca48aa
commit
efd0801cd1
30 files changed
+3393
-178
No files matched your search
@@ -0,0 +1,103 @@
|
||||
"""ACE-Trockner und Platz-Schreiben: Grenzen und Mapping."""
|
||||
|
||||
import pytest
|
||||
|
||||
from grotti.moonraker import (
|
||||
PrinterError,
|
||||
ace_hub_index,
|
||||
extract_dryers,
|
||||
spool_rgb,
|
||||
steuern,
|
||||
)
|
||||
|
||||
|
||||
def test_extract_dryers_skips_dummy_unit():
|
||||
status = {
|
||||
"mmu_machine": {
|
||||
"num_units": 1,
|
||||
"unit_0": {
|
||||
"num_gates": 4,
|
||||
"dryer_status": "drying",
|
||||
"dryer_temp": 44,
|
||||
"dryer_target_temp": 45,
|
||||
"dryer_remaining": 120,
|
||||
"dryer_humidity": 20,
|
||||
},
|
||||
"unit_1": {
|
||||
"num_gates": 0,
|
||||
"dryer_status": "stop",
|
||||
},
|
||||
}
|
||||
}
|
||||
dryers = extract_dryers(status)
|
||||
assert len(dryers) == 1
|
||||
assert dryers[0]["id"] == 0
|
||||
assert dryers[0]["status"] == "drying"
|
||||
assert dryers[0]["target"] == 45
|
||||
assert dryers[0]["remain"] == 120
|
||||
|
||||
|
||||
def test_extract_dryers_empty_without_machine():
|
||||
assert extract_dryers({}) == []
|
||||
assert extract_dryers({"mmu_machine": {}}) == []
|
||||
|
||||
|
||||
def test_ace_hub_index():
|
||||
assert ace_hub_index(1) == (0, 0)
|
||||
assert ace_hub_index(4) == (0, 3)
|
||||
assert ace_hub_index(5) == (1, 0)
|
||||
assert ace_hub_index(8) == (1, 3)
|
||||
with pytest.raises(PrinterError):
|
||||
ace_hub_index(0)
|
||||
with pytest.raises(PrinterError):
|
||||
ace_hub_index(9)
|
||||
|
||||
|
||||
def test_spool_rgb_from_colors():
|
||||
assert spool_rgb({"colors": [{"name": "Blau", "hex": "#002B49"}]}) == {
|
||||
"R": 0, "G": 43, "B": 73,
|
||||
}
|
||||
assert spool_rgb({"colors": [], "color": "Weiß"}) is None
|
||||
assert spool_rgb({"color": "#ff00aa"}) == {"R": 255, "G": 0, "B": 170}
|
||||
|
||||
|
||||
def test_dryer_start_bounds(monkeypatch):
|
||||
calls = []
|
||||
|
||||
def fake_post(host, path, payload, timeout=20):
|
||||
calls.append((host, path, payload))
|
||||
return {"result": "ok"}
|
||||
|
||||
monkeypatch.setattr("grotti.moonraker.post_json", fake_post)
|
||||
steuern("10.10.1.60", "dryer_start", {"id": 0, "temp": 45, "duration": 240})
|
||||
assert calls[0][1] == "/server/filament_hub/start_drying"
|
||||
assert calls[0][2]["fan_speed"] == 0
|
||||
|
||||
with pytest.raises(PrinterError):
|
||||
steuern("10.10.1.60", "dryer_start", {"id": 2, "temp": 45, "duration": 60})
|
||||
with pytest.raises(PrinterError):
|
||||
steuern("10.10.1.60", "dryer_start", {"id": 0, "temp": 20, "duration": 60})
|
||||
with pytest.raises(PrinterError):
|
||||
steuern("10.10.1.60", "dryer_start", {"id": 0, "temp": 45, "duration": 0})
|
||||
|
||||
|
||||
def test_slot_setzen_payload(monkeypatch):
|
||||
calls = []
|
||||
|
||||
def fake_post(host, path, payload, timeout=20):
|
||||
calls.append((host, path, payload))
|
||||
return {"result": "ok"}
|
||||
|
||||
monkeypatch.setattr("grotti.moonraker.post_json", fake_post)
|
||||
steuern(
|
||||
"10.10.1.60",
|
||||
"slot_setzen",
|
||||
{"id": 0, "index": 2, "type": "PLA", "color": {"R": 1, "G": 2, "B": 3}},
|
||||
)
|
||||
assert calls[0][1] == "/printer/filament_hub/set_filament_info"
|
||||
assert calls[0][2] == {
|
||||
"id": 0,
|
||||
"index": 2,
|
||||
"type": "PLA",
|
||||
"color": {"R": 1, "G": 2, "B": 3},
|
||||
}
|
||||
Reference in new issue
Block a user