Files
2026-05-16 19:03:49 +03:00

57 lines
2.0 KiB
Python

from sir import EdgeKind, NodeKind, SemanticEdge, SemanticNode, SirSnapshot, SourceRef
from ui_semantics import form_semantics
def test_form_semantics_groups_commands_and_elements():
form = SemanticNode(
semantic_id="form.main",
lineage_id="lineage.form.main",
kind=NodeKind.FORM,
name="ФормаДокумента",
qualified_name="Документ.Заказ.ФормаДокумента",
source_ref=SourceRef(source_path="form.xml"),
)
command = SemanticNode(
semantic_id="command.post",
lineage_id="lineage.command.post",
kind=NodeKind.COMMAND,
name="Провести",
qualified_name="Документ.Заказ.ФормаДокумента.Провести",
source_ref=SourceRef(source_path="form.xml"),
)
snapshot = SirSnapshot(
snapshot_id="snapshot.ui",
project_id="demo",
nodes=[
form,
command,
SemanticNode(
semantic_id="procedure.post",
lineage_id="lineage.procedure.post",
kind=NodeKind.PROCEDURE,
name="ПровестиКоманда",
qualified_name="Module.ПровестиКоманда",
source_ref=SourceRef(source_path="module.bsl"),
),
],
edges=[
SemanticEdge(
edge_id="edge.command",
kind=EdgeKind.HAS_COMMAND,
source_lineage=form.lineage_id,
target_lineage=command.lineage_id,
),
SemanticEdge(
edge_id="edge.handler",
kind=EdgeKind.HANDLES,
source_lineage=command.lineage_id,
target_lineage="lineage.procedure.post",
),
],
)
forms = form_semantics(snapshot)
assert forms[0].commands[0].name == "Провести"
assert forms[0].command_handlers[command.lineage_id].name == "ПровестиКоманда"