test_model_names_with_spaces_3335.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. """A model stored with a space in its name is found in the model sets (#3335).
  2. Discovery and the add-printer dropdown store an H2D Pro as "H2D Pro". The
  3. checks upper-cased it to "H2D PRO", which no set holds, so an H2D Pro had no
  4. chamber temperature, no chamber heater and no airduct. Every check in
  5. printer_manager now compares the name without spaces.
  6. """
  7. import pytest
  8. from backend.app.services import printer_manager as pm
  9. from backend.app.services.printer_manager import (
  10. drying_screen_only,
  11. has_stg_cur_idle_bug,
  12. supports_airduct,
  13. supports_chamber_heater,
  14. supports_chamber_temp,
  15. supports_drying,
  16. supports_drying_while_printing,
  17. )
  18. H2D_PRO = ["H2D Pro", "h2d pro", " H2D Pro ", "H2DPRO", "O1E", "O2D"]
  19. @pytest.mark.parametrize("model", H2D_PRO)
  20. def test_an_h2d_pro_has_its_chamber_and_airduct(model):
  21. assert supports_chamber_temp(model)
  22. assert supports_chamber_heater(model)
  23. assert supports_airduct(model)
  24. @pytest.mark.parametrize("model", H2D_PRO)
  25. def test_an_h2d_pro_dries_while_printing(model):
  26. assert supports_drying_while_printing(model, "01.02.00.00")
  27. assert not supports_drying_while_printing(model, "01.01.09.00")
  28. @pytest.mark.parametrize("model", ["A1 Mini", "a1 mini", "A1MINI", "A1-MINI", "N1"])
  29. def test_an_a1_mini_is_still_an_a1_mini(model):
  30. assert has_stg_cur_idle_bug(model)
  31. assert not supports_drying(model, "99.99.99.99")
  32. assert not supports_chamber_temp(model)
  33. def test_the_x1c_code_keeps_its_dash():
  34. assert supports_chamber_temp("BL-P001")
  35. assert supports_drying_while_printing("BL-P001", "01.11.02.00")
  36. def test_a_p1s_still_dries_only_from_its_screen():
  37. assert drying_screen_only("p1s")
  38. assert not supports_drying("P1S", "99.99.99.99")
  39. @pytest.mark.parametrize("model", ["X1E", "x1e", "C13"])
  40. def test_the_x1e_heats_its_chamber_but_has_no_airduct(model):
  41. assert supports_chamber_heater(model)
  42. assert supports_chamber_temp(model)
  43. assert not supports_airduct(model)
  44. @pytest.mark.parametrize("model", ["X1C", "BL-P001", "P2S", "N7"])
  45. def test_sensor_only_chambers_have_no_heater(model):
  46. assert supports_chamber_temp(model)
  47. assert not supports_chamber_heater(model)
  48. def _model_tables():
  49. for name in dir(pm):
  50. value = getattr(pm, name)
  51. if "MODEL" in name or "FIRMWARE" in name:
  52. if isinstance(value, (frozenset, set, dict)):
  53. yield name, value
  54. def test_no_set_holds_a_name_the_checks_cannot_match():
  55. tables = dict(_model_tables())
  56. assert len(tables) >= 8 # the scan finds the sets at all
  57. unmatchable = {
  58. name: sorted(key for key in table if key != key.strip().upper().replace(" ", ""))
  59. for name, table in tables.items()
  60. }
  61. assert {name: keys for name, keys in unmatchable.items() if keys} == {}