Files
dxdesigner-part-replacement/tests/conftest.py
T

29 lines
1.1 KiB
Python

from decimal import Decimal
import pytest
from dx_productivity.part_replace.models import ComponentSnapshot, DesignSnapshot, PinSnapshot, UnitSnapshot
@pytest.fixture(autouse=True)
def accept_minimal_project_placeholders(monkeypatch: pytest.MonkeyPatch, request: pytest.FixtureRequest) -> None:
if request.node.path.name != "test_scanner.py":
monkeypatch.setattr(
"dx_productivity.trial_task_center.scanner._is_schematic_project",
lambda _path: True,
)
@pytest.fixture
def snapshot_factory():
"""Return a fresh minimal snapshot factory for tests."""
def make(project_id: str = "p1", part_number: str = "OLD-1") -> DesignSnapshot:
pin = PinSnapshot("1", "A", Decimal("10.25"), Decimal("20"), "N$1")
unit = UnitSnapshot(
"u1", "/MAIN", "res.1", Decimal("0"), Decimal("0"),
Decimal("0"), Decimal("0"), 0, False, (pin,),
)
component = ComponentSnapshot("/MAIN|R1", "R1", part_number, (unit,), ())
return DesignSnapshot(2, project_id, "C:/P/a.prj", "abc", (component,))
return make