Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pythonised popupGroupSupport test #535

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading