mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
Fix P2S showing carbon rod maintenance tasks (#640)
P2S uses hardened steel rods, not carbon fiber. Move P2S from carbon rod classification to new steel_rod category with its own "Lubricate Steel Rods" / "Clean Steel Rods" maintenance tasks.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Unit tests for maintenance rod-type filtering logic."""
|
||||
|
||||
import pytest
|
||||
|
||||
from backend.app.api.routes.maintenance import _should_apply_to_printer
|
||||
|
||||
|
||||
class TestShouldApplyToPrinter:
|
||||
"""Tests for _should_apply_to_printer() model-specific filtering."""
|
||||
|
||||
# Carbon rod tasks should only apply to X1/P1 models
|
||||
@pytest.mark.parametrize("model", ["X1C", "X1", "X1E", "P1P", "P1S"])
|
||||
def test_carbon_rod_tasks_apply_to_carbon_models(self, model: str):
|
||||
assert _should_apply_to_printer("Lubricate Carbon Rods", model) is True
|
||||
assert _should_apply_to_printer("Clean Carbon Rods", model) is True
|
||||
|
||||
def test_carbon_rod_tasks_do_not_apply_to_p2s(self):
|
||||
"""P2S has steel rods, not carbon rods (#640)."""
|
||||
assert _should_apply_to_printer("Lubricate Carbon Rods", "P2S") is False
|
||||
assert _should_apply_to_printer("Clean Carbon Rods", "P2S") is False
|
||||
|
||||
def test_carbon_rod_tasks_do_not_apply_to_a1(self):
|
||||
assert _should_apply_to_printer("Lubricate Carbon Rods", "A1") is False
|
||||
|
||||
# Steel rod tasks should only apply to P2S
|
||||
def test_steel_rod_tasks_apply_to_p2s(self):
|
||||
assert _should_apply_to_printer("Lubricate Steel Rods", "P2S") is True
|
||||
assert _should_apply_to_printer("Clean Steel Rods", "P2S") is True
|
||||
|
||||
def test_steel_rod_tasks_do_not_apply_to_x1c(self):
|
||||
assert _should_apply_to_printer("Lubricate Steel Rods", "X1C") is False
|
||||
assert _should_apply_to_printer("Clean Steel Rods", "X1C") is False
|
||||
|
||||
def test_steel_rod_tasks_do_not_apply_to_a1(self):
|
||||
assert _should_apply_to_printer("Lubricate Steel Rods", "A1") is False
|
||||
|
||||
# Linear rail tasks should only apply to A1/H2 models
|
||||
@pytest.mark.parametrize("model", ["A1", "A1 Mini", "H2D", "H2C", "H2S"])
|
||||
def test_linear_rail_tasks_apply_to_rail_models(self, model: str):
|
||||
assert _should_apply_to_printer("Lubricate Linear Rails", model) is True
|
||||
assert _should_apply_to_printer("Clean Linear Rails", model) is True
|
||||
|
||||
def test_linear_rail_tasks_do_not_apply_to_p2s(self):
|
||||
assert _should_apply_to_printer("Lubricate Linear Rails", "P2S") is False
|
||||
|
||||
# Universal tasks apply to all models
|
||||
@pytest.mark.parametrize("model", ["X1C", "P2S", "A1", "H2D"])
|
||||
def test_universal_tasks_apply_to_all(self, model: str):
|
||||
assert _should_apply_to_printer("Clean Nozzle/Hotend", model) is True
|
||||
assert _should_apply_to_printer("Check Belt Tension", model) is True
|
||||
|
||||
# Unknown models default to carbon (legacy behavior)
|
||||
def test_unknown_model_defaults_to_carbon(self):
|
||||
assert _should_apply_to_printer("Lubricate Carbon Rods", "UNKNOWN") is True
|
||||
assert _should_apply_to_printer("Lubricate Steel Rods", "UNKNOWN") is False
|
||||
assert _should_apply_to_printer("Lubricate Linear Rails", "UNKNOWN") is False
|
||||
@@ -0,0 +1,48 @@
|
||||
"""Unit tests for printer model utilities."""
|
||||
|
||||
import pytest
|
||||
|
||||
from backend.app.utils.printer_models import get_rod_type
|
||||
|
||||
|
||||
class TestGetRodType:
|
||||
"""Tests for get_rod_type() rod/rail classification."""
|
||||
|
||||
@pytest.mark.parametrize("model", ["X1C", "X1", "X1E", "P1P", "P1S"])
|
||||
def test_carbon_rod_models(self, model: str):
|
||||
assert get_rod_type(model) == "carbon"
|
||||
|
||||
@pytest.mark.parametrize("model", ["C11", "C12", "C13"])
|
||||
def test_carbon_rod_internal_codes(self, model: str):
|
||||
assert get_rod_type(model) == "carbon"
|
||||
|
||||
def test_p2s_is_steel_rod(self):
|
||||
"""P2S uses hardened steel rods, not carbon rods (#640)."""
|
||||
assert get_rod_type("P2S") == "steel_rod"
|
||||
|
||||
def test_p2s_internal_code_is_steel_rod(self):
|
||||
"""N7 (P2S internal code) uses steel rods."""
|
||||
assert get_rod_type("N7") == "steel_rod"
|
||||
|
||||
@pytest.mark.parametrize("model", ["A1", "A1 Mini", "H2D", "H2D Pro", "H2C", "H2S"])
|
||||
def test_linear_rail_models(self, model: str):
|
||||
assert get_rod_type(model) == "linear_rail"
|
||||
|
||||
@pytest.mark.parametrize("model", ["N1", "N2S", "A11", "A12", "O1D", "O1E", "O2D", "O1C", "O1C2", "O1S"])
|
||||
def test_linear_rail_internal_codes(self, model: str):
|
||||
assert get_rod_type(model) == "linear_rail"
|
||||
|
||||
def test_unknown_model_returns_none(self):
|
||||
assert get_rod_type("UNKNOWN") is None
|
||||
|
||||
def test_none_returns_none(self):
|
||||
assert get_rod_type(None) is None
|
||||
|
||||
def test_case_insensitive(self):
|
||||
assert get_rod_type("p2s") == "steel_rod"
|
||||
assert get_rod_type("x1c") == "carbon"
|
||||
assert get_rod_type("a1") == "linear_rail"
|
||||
|
||||
def test_strips_whitespace_and_dashes(self):
|
||||
assert get_rod_type(" P2S ") == "steel_rod"
|
||||
assert get_rod_type("A1-Mini") == "linear_rail"
|
||||
Reference in New Issue
Block a user