82 lines
2.2 KiB
Python
82 lines
2.2 KiB
Python
from dx_productivity.domain.models import Severity
|
|
from dx_productivity.domain.validation import validate_plan
|
|
|
|
|
|
def test_validation_blocks_duplicate_source_formal_refdes(
|
|
component_factory, snapshot_factory, plan_row_factory
|
|
):
|
|
first = component_factory(
|
|
bridge_id="a",
|
|
stable_uid="a",
|
|
logical_group_key="a",
|
|
refdes="R1",
|
|
)
|
|
second = component_factory(
|
|
bridge_id="b",
|
|
stable_uid="b",
|
|
logical_group_key="b",
|
|
refdes="r1",
|
|
)
|
|
snapshot = snapshot_factory(components=(first, second))
|
|
|
|
issues = validate_plan(snapshot, ())
|
|
|
|
assert any(
|
|
issue.code == "duplicate-source-refdes"
|
|
and issue.severity is Severity.BLOCKING
|
|
for issue in issues
|
|
)
|
|
|
|
|
|
def test_validation_blocks_duplicate_proposed_output(
|
|
snapshot_factory, plan_row_factory
|
|
):
|
|
rows = (
|
|
plan_row_factory("a", "R?", "R1", logical_key="a"),
|
|
plan_row_factory("b", "R?", "r1", logical_key="b"),
|
|
)
|
|
|
|
issues = validate_plan(snapshot_factory(), rows)
|
|
|
|
assert any(issue.code == "duplicate-proposed-refdes" for issue in issues)
|
|
|
|
|
|
def test_validation_blocks_output_occupied_outside_target(
|
|
component_factory, snapshot_factory, plan_row_factory
|
|
):
|
|
target = component_factory(refdes="R?")
|
|
outside = component_factory(
|
|
bridge_id="outside",
|
|
stable_uid="outside",
|
|
logical_group_key="outside",
|
|
refdes="R1",
|
|
selected=False,
|
|
)
|
|
snapshot = snapshot_factory(components=(target, outside))
|
|
rows = (plan_row_factory("c0001", "R?", "R1"),)
|
|
|
|
issues = validate_plan(snapshot, rows)
|
|
|
|
assert any(issue.code == "occupied-output" for issue in issues)
|
|
|
|
|
|
def test_validation_allows_same_refdes_on_members_of_one_logical_component(
|
|
component_factory, snapshot_factory
|
|
):
|
|
first = component_factory(
|
|
bridge_id="u1a",
|
|
stable_uid="u1",
|
|
logical_group_key="u1",
|
|
refdes="U1",
|
|
)
|
|
second = component_factory(
|
|
bridge_id="u1b",
|
|
stable_uid="u1",
|
|
logical_group_key="u1",
|
|
refdes="U1",
|
|
)
|
|
|
|
issues = validate_plan(snapshot_factory(components=(first, second)), ())
|
|
|
|
assert not [issue for issue in issues if issue.code == "duplicate-source-refdes"]
|