Files
bambuddy/backend/tests/unit/test_filament_fields_options.py
T
maziggy bfbf5d59af fix(profiles): add PLA-CF + Bambu CF/GF/specialty variants to filament_type select (#1686)
The Profiles page edit modal (shared by BL Cloud / Orca Cloud / Local
  Profiles) renders filament_type from backend/app/data/filament_fields.json
  via GET /cloud/fields/filament. The curated 11-option list pre-dated Bambu's
  CF/GF lineup expansion, so PLA-CF and most carbon/glass-fiber variants were
  unselectable — saved presets carried the wrong material code at dispatch.

  Expanded to 25 BambuStudio-aligned options grouped by family: PLA (+ CF/GF/
  AERO), PETG (+ CF), ABS (+ GF), ASA (+ CF/GF), PC, PCTG, PA family (+ CF/
  PAHT-CF/PA6-CF/PA6-GF), PET-CF, TPU, PPS family (+ CF/GF for X1E), PVA, HIPS.

  K-profiles editor unaffected (picks filament_id, not filament_type).
2026-06-09 07:38:59 +02:00

54 lines
1.5 KiB
Python

"""Regression pin for the filament_type select options exposed by
GET /cloud/fields/filament — used by the Profiles edit modal.
Issue #1686: PLA-CF and other CF/GF variants were missing from the dropdown,
so users could not tag custom presets with the correct material type.
"""
import json
from pathlib import Path
import pytest
FIELDS_PATH = Path(__file__).resolve().parents[2] / "app" / "data" / "filament_fields.json"
@pytest.fixture(scope="module")
def filament_type_options() -> set[str]:
with FIELDS_PATH.open() as f:
data = json.load(f)
field = next(f for f in data["fields"] if f["key"] == "filament_type")
return {opt["value"] for opt in field["options"]}
@pytest.mark.parametrize(
"material",
[
# Reported in #1686
"PLA-CF",
# Other Bambu CF / GF / specialty variants that share the same gap
"PLA-GF",
"PLA-AERO",
"PETG-CF",
"ABS-GF",
"ASA-CF",
"ASA-GF",
"PCTG",
"PAHT-CF",
"PA6-CF",
"PA6-GF",
"PPS",
"PPS-CF",
"PPS-GF",
],
)
def test_filament_type_includes_carbon_and_glass_fiber_variants(filament_type_options: set[str], material: str) -> None:
assert material in filament_type_options
def test_filament_type_keeps_baseline_materials(
filament_type_options: set[str],
) -> None:
baseline = {"PLA", "PETG", "ABS", "ASA", "PC", "PA", "PA-CF", "PET-CF", "TPU", "PVA", "HIPS"}
assert baseline.issubset(filament_type_options)