Test deletion of RerouteNode objects.
()
| 18 | from core.reroute_node import RerouteNode |
| 19 | |
| 20 | def test_reroute_node_deletion(): |
| 21 | """Test deletion of RerouteNode objects.""" |
| 22 | |
| 23 | app = QApplication.instance() |
| 24 | if app is None: |
| 25 | app = QApplication(sys.argv) |
| 26 | |
| 27 | window = NodeEditorWindow() |
| 28 | graph = window.graph |
| 29 | |
| 30 | # Clear any existing content |
| 31 | graph.clear_graph() |
| 32 | |
| 33 | print("Creating test setup with RerouteNode...") |
| 34 | |
| 35 | # Create a regular node |
| 36 | node1 = graph.create_node("Test Node", pos=(100, 100)) |
| 37 | node1.set_code(''' |
| 38 | @node_entry |
| 39 | def test_function() -> str: |
| 40 | return "test_output" |
| 41 | ''') |
| 42 | |
| 43 | # Create a RerouteNode |
| 44 | reroute = RerouteNode() |
| 45 | reroute.setPos(300, 100) |
| 46 | graph.addItem(reroute) |
| 47 | graph.nodes.append(reroute) |
| 48 | |
| 49 | # Create another regular node |
| 50 | node2 = graph.create_node("Test Node 2", pos=(500, 100)) |
| 51 | node2.set_code(''' |
| 52 | @node_entry |
| 53 | def test_function_2(input_val: str): |
| 54 | print(input_val) |
| 55 | ''') |
| 56 | |
| 57 | print(f"Initial state:") |
| 58 | print(f" Nodes: {len(graph.nodes)}") |
| 59 | print(f" Scene items: {len(graph.items())}") |
| 60 | |
| 61 | # Create connections: node1 -> reroute -> node2 |
| 62 | print("Creating connections...") |
| 63 | if node1.output_pins and node2.input_pins: |
| 64 | # Connect node1 to reroute |
| 65 | conn1 = graph.create_connection(node1.output_pins[0], reroute.input_pin) |
| 66 | print(f"Created connection: node1 -> reroute") |
| 67 | |
| 68 | # Connect reroute to node2 |
| 69 | conn2 = graph.create_connection(reroute.output_pin, node2.input_pins[0]) |
| 70 | print(f"Created connection: reroute -> node2") |
| 71 | |
| 72 | print(f"After connections:") |
| 73 | print(f" Nodes: {len(graph.nodes)}") |
| 74 | print(f" Connections: {len(graph.connections)}") |
| 75 | print(f" Scene items: {len(graph.items())}") |
| 76 | |
| 77 | # Verify RerouteNode structure |
no test coverage detected