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,96 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from dx_productivity.domain.models import AttributeRecord, OpType, Severity
|
||||
from dx_productivity.features.property_visibility import (
|
||||
PropertyVisibilitySettings,
|
||||
build_property_visibility_plan,
|
||||
)
|
||||
|
||||
|
||||
def _component(component_factory, visible, **overrides):
|
||||
return component_factory(
|
||||
attributes=(
|
||||
AttributeRecord(name="Part Name", value="RES", visible=visible),
|
||||
),
|
||||
**overrides,
|
||||
)
|
||||
|
||||
|
||||
def test_hide_selected_components(component_factory, snapshot_factory):
|
||||
component = _component(component_factory, True)
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
plan = build_property_visibility_plan(
|
||||
snapshot, PropertyVisibilitySettings(visible=False)
|
||||
)
|
||||
|
||||
assert plan.can_apply
|
||||
assert plan.rows[0].changed is True
|
||||
assert plan.schedule[0].op is OpType.PROPERTY_VISIBILITY
|
||||
assert plan.schedule[0].property_name == "Part Name"
|
||||
assert plan.schedule[0].expected_refdes == "1"
|
||||
assert plan.schedule[0].new_refdes == "0"
|
||||
|
||||
|
||||
def test_show_restores_hidden_attribute(component_factory, snapshot_factory):
|
||||
component = _component(component_factory, False)
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
plan = build_property_visibility_plan(
|
||||
snapshot, PropertyVisibilitySettings(visible=True)
|
||||
)
|
||||
|
||||
assert plan.can_apply
|
||||
assert plan.schedule[0].new_refdes == "1"
|
||||
|
||||
|
||||
def test_already_hidden_component_is_preserved(
|
||||
component_factory, snapshot_factory
|
||||
):
|
||||
component = _component(component_factory, False)
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
plan = build_property_visibility_plan(
|
||||
snapshot, PropertyVisibilitySettings(visible=False)
|
||||
)
|
||||
|
||||
assert plan.rows[0].changed is False
|
||||
assert plan.schedule == ()
|
||||
assert not plan.can_apply
|
||||
|
||||
|
||||
def test_missing_attribute_is_reported(component_factory, snapshot_factory):
|
||||
component = component_factory(attributes=())
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
plan = build_property_visibility_plan(
|
||||
snapshot, PropertyVisibilitySettings(visible=False)
|
||||
)
|
||||
|
||||
assert any(issue.code == "skipped-missing" for issue in plan.issues)
|
||||
|
||||
|
||||
def test_locked_components_are_skipped(component_factory, snapshot_factory):
|
||||
component = _component(component_factory, True, locked=True)
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
plan = build_property_visibility_plan(
|
||||
snapshot, PropertyVisibilitySettings(visible=False)
|
||||
)
|
||||
|
||||
assert any(issue.code == "skipped-locked" for issue in plan.issues)
|
||||
assert plan.rows[0].changed is False
|
||||
|
||||
|
||||
def test_unselected_components_are_ignored(
|
||||
component_factory, snapshot_factory
|
||||
):
|
||||
component = _component(component_factory, True, selected=False)
|
||||
snapshot = snapshot_factory(components=(component,))
|
||||
|
||||
plan = build_property_visibility_plan(
|
||||
snapshot, PropertyVisibilitySettings(visible=False)
|
||||
)
|
||||
|
||||
assert plan.rows == ()
|
||||
assert plan.schedule == ()
|
||||
Reference in new issue
Block a user