feat: add complete yiyezhqiu productivity suite
This commit is contained in:
commit
e422ca8b2a
155 files changed
+18959
No files matched your search
@@ -0,0 +1,112 @@
|
||||
from dx_productivity.domain.models import AttributeRecord, NetRecord
|
||||
from dx_productivity.features.inspection import (
|
||||
has_net_data,
|
||||
missing_attribute_values,
|
||||
net_cross_page,
|
||||
net_list,
|
||||
solitary_nets,
|
||||
)
|
||||
|
||||
|
||||
def _snapshot_factory(snapshot_factory, nets, components=()):
|
||||
if not components and nets == ():
|
||||
return snapshot_factory()
|
||||
return snapshot_factory(components=components, nets=nets)
|
||||
|
||||
|
||||
def test_solitary_nets_found(snapshot_factory, component_factory):
|
||||
snapshot = snapshot_factory(
|
||||
nets=(
|
||||
NetRecord(name="N1", pages=(1,)),
|
||||
NetRecord(name="N2", pages=(1, 2)),
|
||||
)
|
||||
)
|
||||
|
||||
rows = solitary_nets(snapshot)
|
||||
|
||||
assert len(rows) == 1
|
||||
assert rows[0].name == "N1"
|
||||
assert rows[0].locate_net is True
|
||||
|
||||
|
||||
def test_net_list_covers_all(snapshot_factory):
|
||||
snapshot = snapshot_factory(
|
||||
nets=(
|
||||
NetRecord(name="N1", pages=(1,)),
|
||||
NetRecord(name="N2", pages=(1, 2)),
|
||||
)
|
||||
)
|
||||
|
||||
assert len(net_list(snapshot)) == 2
|
||||
|
||||
|
||||
def test_cross_page_lookup(snapshot_factory):
|
||||
snapshot = snapshot_factory(nets=(NetRecord(name="N2", pages=(1, 2)),))
|
||||
|
||||
rows = net_cross_page(snapshot, "n2")
|
||||
|
||||
assert [row.pages[0] for row in rows] == [1, 2]
|
||||
assert net_cross_page(snapshot, "missing") == []
|
||||
|
||||
|
||||
def test_value_miss_flags_empty_values_only_by_default(
|
||||
component_factory, snapshot_factory
|
||||
):
|
||||
empty = component_factory(
|
||||
bridge_id="c1",
|
||||
attributes=(AttributeRecord(name="Value", value="", visible=True),),
|
||||
)
|
||||
missing = component_factory(
|
||||
bridge_id="c2",
|
||||
stable_uid="uid-c2",
|
||||
full_path="ROOT\C2",
|
||||
logical_group_key="uid-c2",
|
||||
attributes=(),
|
||||
)
|
||||
ok = component_factory(
|
||||
bridge_id="c3",
|
||||
stable_uid="uid-c3",
|
||||
full_path="ROOT\C3",
|
||||
logical_group_key="uid-c3",
|
||||
attributes=(AttributeRecord(name="Value", value="10K", visible=True),),
|
||||
)
|
||||
snapshot = snapshot_factory(components=(empty, missing, ok))
|
||||
|
||||
rows = missing_attribute_values(snapshot, "Value")
|
||||
|
||||
assert len(rows) == 1
|
||||
assert rows[0].detail == "属性值为空"
|
||||
assert rows[0].locate_bridge_id == "c1"
|
||||
|
||||
|
||||
def test_value_miss_include_missing_option(component_factory, snapshot_factory):
|
||||
missing = component_factory(
|
||||
bridge_id="c2",
|
||||
attributes=(),
|
||||
)
|
||||
snapshot = snapshot_factory(components=(missing,))
|
||||
|
||||
rows = missing_attribute_values(
|
||||
snapshot, "Value", include_missing=True
|
||||
)
|
||||
|
||||
assert len(rows) == 1
|
||||
assert rows[0].detail == "属性缺失"
|
||||
|
||||
|
||||
def test_unnamed_components_are_skipped(component_factory, snapshot_factory):
|
||||
component = component_factory(
|
||||
refdes="",
|
||||
attributes=(AttributeRecord(name="Value", value="", visible=True),),
|
||||
)
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
assert missing_attribute_values(snapshot, "Value") == []
|
||||
|
||||
|
||||
def test_has_net_data(snapshot_factory):
|
||||
empty = snapshot_factory()
|
||||
populated = snapshot_factory(nets=(NetRecord(name="N1", pages=(1,)),))
|
||||
|
||||
assert has_net_data(empty) is False
|
||||
assert has_net_data(populated) is True
|
||||
Reference in new issue
Block a user