Skip to content

Commit

Permalink
pythonised popupGroupSupport test
Browse files Browse the repository at this point in the history
  • Loading branch information
wdednam committed Dec 16, 2024
1 parent d8da3a1 commit 89494c6
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions test/00/popupGroupSupport.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,44 @@ pass()
}

trap "fail" 1 2 3 15
cat >input.py <<EOF
import sys
sys.path.insert(0, '$here')
from pyminsky import minsky
cat >input.tcl <<EOF
source $here/test/assert.tcl
minsky.load $here/examples/GoodwinLinear02.mky
# find the group item
minsky.model.groups.@elem 0
minsky.getItemAt [minsky.model.groups(0).x] [minsky.model.groups(0).y]
assert {[minsky.canvas.item.classType]=="Group"}
minsky.openGroupInCanvas
assert {[minsky.model.groups(0).numItems]==[minsky.canvas.model.numItems]}
assert {[minsky.model.groups(0).numWires]==[minsky.canvas.model.numWires]}
minsky.openModelInCanvas
assert {[minsky.model.numItems]==[minsky.canvas.model.numItems]}
assert {[minsky.model.numWires]==[minsky.canvas.model.numWires]}
tcl_exit
# Load the model
minsky.load('$here/examples/GoodwinLinear02.mky')
# Step 1: Access the first group directly from minsky.model.groups
group = minsky.model.groups[0]
assert group is not None, "No group found in the model."
print(f"Found group at coordinates ({group.x()}, {group.y()})")
# Step 2: Focus on the group item on the canvas
minsky.canvas.getItemAt(group.x(), group.y())
assert minsky.canvas.item.classType() == "Group", "Focused item is not a Group."
# Step 3: Open the group in the canvas
minsky.openGroupInCanvas()
# Step 4: Verify the number of items and wires in the group matches the canvas
group_model = group
canvas_model = minsky.canvas.model
assert group_model.numItems() == canvas_model.numItems(), "Number of items in the group and canvas do not match."
assert group_model.numWires() == canvas_model.numWires(), "Number of wires in the group and canvas do not match."
print("Group and canvas models match in terms of items and wires.")
# Step 5: Return to the main model in the canvas
minsky.openModelInCanvas()
# Step 6: Verify the number of items and wires in the main model matches the canvas
assert minsky.model.numItems() == minsky.canvas.model.numItems(), "Number of items in the main model and canvas do not match."
assert minsky.model.numWires() == minsky.canvas.model.numWires(), "Number of wires in the main model and canvas do not match."
EOF

$here/gui-tk/minsky input.tcl
python3 input.py
if [ $? -ne 0 ]; then fail; fi

pass

0 comments on commit 89494c6

Please sign in to comment.