test_ws_status_carries_rest_fields.py 1.1 KB

123456789101112131415161718192021222324252627
  1. """The live status push carries what the printer card reads from the status (PSF-3, PSF-4).
  2. The websocket push replaces the fields it carries in the card's cached status.
  3. ``airduct_mode`` was missing, so switching cooling/heating on the printer's
  4. screen showed the old mode until the next REST poll; ``nozzle_rack[]`` lacked
  5. ``filament_type``, and since the push replaces the whole rack an H2C slot
  6. lost its material label on every push.
  7. """
  8. import backend.app.core.database # noqa: F401 -- model import order
  9. from backend.app.services.bambu_mqtt import PrinterState
  10. from backend.app.services.printer_manager import printer_state_to_dict
  11. def test_the_airduct_mode_is_pushed():
  12. state = PrinterState()
  13. state.airduct_mode = 1
  14. assert printer_state_to_dict(state)["airduct_mode"] == 1
  15. def test_a_rack_slot_keeps_its_material():
  16. state = PrinterState()
  17. state.nozzle_rack = [{"id": 2, "type": "HS", "diameter": "0.4", "filament_id": "GFL99", "filament_type": "PLA"}]
  18. [slot] = printer_state_to_dict(state)["nozzle_rack"]
  19. assert slot["filament_type"] == "PLA"