test_filament_fields_options.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """Regression pin for the filament_type select options exposed by
  2. GET /cloud/fields/filament — used by the Profiles edit modal.
  3. Issue #1686: PLA-CF and other CF/GF variants were missing from the dropdown,
  4. so users could not tag custom presets with the correct material type.
  5. """
  6. import json
  7. from pathlib import Path
  8. import pytest
  9. FIELDS_PATH = Path(__file__).resolve().parents[2] / "app" / "data" / "filament_fields.json"
  10. @pytest.fixture(scope="module")
  11. def filament_type_options() -> set[str]:
  12. with FIELDS_PATH.open() as f:
  13. data = json.load(f)
  14. field = next(f for f in data["fields"] if f["key"] == "filament_type")
  15. return {opt["value"] for opt in field["options"]}
  16. @pytest.mark.parametrize(
  17. "material",
  18. [
  19. # Reported in #1686
  20. "PLA-CF",
  21. # Other Bambu CF / GF / specialty variants that share the same gap
  22. "PLA-GF",
  23. "PLA-AERO",
  24. "PETG-CF",
  25. "ABS-GF",
  26. "ASA-CF",
  27. "ASA-GF",
  28. "PCTG",
  29. "PAHT-CF",
  30. "PA6-CF",
  31. "PA6-GF",
  32. "PPS",
  33. "PPS-CF",
  34. "PPS-GF",
  35. ],
  36. )
  37. def test_filament_type_includes_carbon_and_glass_fiber_variants(filament_type_options: set[str], material: str) -> None:
  38. assert material in filament_type_options
  39. def test_filament_type_keeps_baseline_materials(
  40. filament_type_options: set[str],
  41. ) -> None:
  42. baseline = {"PLA", "PETG", "ABS", "ASA", "PC", "PA", "PA-CF", "PET-CF", "TPU", "PVA", "HIPS"}
  43. assert baseline.issubset(filament_type_options)