Grotti 3.0.0: Aufträge, Wartung, SSE, Ausschuss-Dialog, UI-Umbau.
Migrationen 003–009, Kundaufträge mit Lieferschein, Abräumen mit Urteil, ntfy/Backup/Zeitfenster, Live-Stream und Mobile-Mehr-Menü.
This commit is contained in:
1 parent
0236278929
commit
8e88efc094
45 files changed
+3121
-122
No files matched your search
@@ -0,0 +1,70 @@
|
||||
"""Filament-Bedarf aus Queue und Spulen."""
|
||||
|
||||
import unittest
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
|
||||
from grotti.bedarf import compute
|
||||
|
||||
|
||||
class BedarfTests(unittest.TestCase):
|
||||
def _rows(self, *lists):
|
||||
mocks = []
|
||||
for rows in lists:
|
||||
m = MagicMock()
|
||||
m.fetchall.return_value = rows
|
||||
mocks.append(m)
|
||||
return mocks
|
||||
|
||||
def test_shortfall_when_queue_exceeds_stock(self):
|
||||
conn = MagicMock()
|
||||
conn.execute.side_effect = self._rows(
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"spool_id": 10,
|
||||
"repeat_total": 2,
|
||||
"repeat_done": 0,
|
||||
"weight_g": 50.0,
|
||||
"file_material": "PLA",
|
||||
"file_color": "Schwarz",
|
||||
"spool_material": "PLA",
|
||||
"spool_color": "Schwarz",
|
||||
},
|
||||
],
|
||||
[
|
||||
{"material_type": "PLA", "color": "Schwarz", "remaining_g": 40.0},
|
||||
],
|
||||
)
|
||||
out = compute(conn)
|
||||
self.assertEqual(len(out["needed"]), 1)
|
||||
self.assertAlmostEqual(out["needed"][0]["weight_g"], 100.0)
|
||||
self.assertEqual(len(out["shortfall"]), 1)
|
||||
self.assertAlmostEqual(out["shortfall"][0]["shortfall_g"], 60.0)
|
||||
|
||||
def test_no_shortfall_when_enough_filament(self):
|
||||
conn = MagicMock()
|
||||
conn.execute.side_effect = self._rows(
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"spool_id": None,
|
||||
"repeat_total": 1,
|
||||
"repeat_done": 0,
|
||||
"weight_g": 20.0,
|
||||
"file_material": "PETG",
|
||||
"file_color": "",
|
||||
"spool_material": None,
|
||||
"spool_color": None,
|
||||
},
|
||||
],
|
||||
[
|
||||
{"material_type": "PETG", "color": "", "remaining_g": 500.0},
|
||||
],
|
||||
)
|
||||
out = compute(conn)
|
||||
self.assertEqual(out["shortfall"], [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user