MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / test_user_scenario

Function test_user_scenario

tests/test_user_scenario_gui.py:21–97  ·  view source on GitHub ↗

Test the exact user scenario: delete reroute, undo it.

()

Source from the content-addressed store, hash-verified

19from core.reroute_node import RerouteNode
20
21def test_user_scenario():
22 """Test the exact user scenario: delete reroute, undo it."""
23
24 app = QApplication.instance()
25 if app is None:
26 app = QApplication(sys.argv)
27
28 window = NodeEditorWindow()
29 graph = window.graph
30 view = window.view
31
32 # Clear any existing content
33 graph.clear_graph()
34
35 print("Creating RerouteNode...")
36
37 # Create a RerouteNode manually (like user would do)
38 reroute = RerouteNode()
39 reroute.setPos(300, 100)
40 graph.addItem(reroute)
41 graph.nodes.append(reroute)
42
43 print(f"Initial state:")
44 print(f" Nodes: {len(graph.nodes)}")
45 print(f" RerouteNode type: {type(reroute).__name__}")
46 print(f" RerouteNode title: {reroute.title}")
47 print(f" RerouteNode has input_pin: {hasattr(reroute, 'input_pin')}")
48 print(f" RerouteNode has output_pin: {hasattr(reroute, 'output_pin')}")
49
50 # Step 1: Delete the RerouteNode
51 print(f"\nStep 1: Deleting RerouteNode...")
52 reroute.setSelected(True)
53 delete_event = QKeyEvent(QKeyEvent.KeyPress, Qt.Key_Delete, Qt.NoModifier)
54 graph.keyPressEvent(delete_event)
55 app.processEvents()
56
57 print(f"After deletion:")
58 print(f" Nodes: {len(graph.nodes)}")
59
60 # Step 2: Undo the deletion (this is where the user saw the issue)
61 print(f"\nStep 2: Undoing deletion (this is where the user reported the issue)...")
62 undo_event = QKeyEvent(QKeyEvent.KeyPress, Qt.Key_Z, Qt.ControlModifier)
63 view.keyPressEvent(undo_event)
64 app.processEvents()
65
66 print(f"After undo:")
67 print(f" Nodes: {len(graph.nodes)}")
68
69 # Check what type of node was restored
70 if len(graph.nodes) > 0:
71 restored_node = None
72 for node in graph.nodes:
73 if hasattr(node, 'title') and node.title == "Reroute":
74 restored_node = node
75 break
76
77 if restored_node:
78 print(f"\nRestored node details:")

Callers 1

Calls 5

NodeEditorWindowClass · 0.90
RerouteNodeClass · 0.90
clear_graphMethod · 0.80
setSelectedMethod · 0.80
keyPressEventMethod · 0.45

Tested by

no test coverage detected