test_h2d_pro_status_3335.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. """An H2D Pro reports its chamber in status (#3335).
  2. The status route drops the chamber readings of models without a chamber
  3. sensor and reports whether the chamber heater can be set. An H2D Pro, stored
  4. as "H2D Pro", was treated as having neither.
  5. """
  6. from unittest.mock import MagicMock, patch
  7. import pytest
  8. from backend.app.services.bambu_mqtt import PrinterState
  9. pytestmark = [pytest.mark.asyncio, pytest.mark.integration]
  10. @pytest.mark.parametrize("model", ["H2D Pro", "X1E"])
  11. async def test_the_chamber_is_reported_and_can_be_heated(async_client, printer_factory, model):
  12. printer = await printer_factory(model=model)
  13. state = PrinterState()
  14. state.connected = True
  15. state.state = "IDLE"
  16. state.temperatures = {"nozzle": 25.0, "bed": 25.0, "chamber": 31.0, "chamber_target": 0.0}
  17. with patch("backend.app.api.routes.printers.printer_manager") as manager:
  18. manager.get_status = MagicMock(return_value=state)
  19. manager.is_awaiting_plate_clear = MagicMock(return_value=False)
  20. response = await async_client.get(f"/api/v1/printers/{printer.id}/status")
  21. assert response.status_code == 200
  22. body = response.json()
  23. assert body["temperatures"]["chamber"] == 31.0
  24. assert body["supports_chamber_heater"] is True