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

Method test_node_removal

tests/test_graph_management.py:94–127  ·  view source on GitHub ↗

Test removing nodes from the graph.

(self)

Source from the content-addressed store, hash-verified

92 self.assertEqual(len(self.graph.nodes), 3) # Including reroute
93
94 def test_node_removal(self):
95 """Test removing nodes from the graph."""
96 # Create test nodes
97 node1 = self.graph.create_node("Node 1", pos=(0, 0))
98 node2 = self.graph.create_node("Node 2", pos=(200, 0))
99
100 # Add some code to create pins
101 node1.set_code('''
102@node_entry
103def test1() -> str:
104 return "test"
105''')
106
107 node2.set_code('''
108@node_entry
109def test2(input_val: str) -> str:
110 return input_val.upper()
111''')
112
113 # Create connection between nodes
114 output_pin = next(p for p in node1.output_pins if p.pin_category == "data")
115 input_pin = next(p for p in node2.input_pins if p.pin_category == "data")
116 connection = self.graph.create_connection(output_pin, input_pin)
117
118 self.assertEqual(len(self.graph.nodes), 2)
119 self.assertEqual(len(self.graph.connections), 1)
120
121 # Remove node1 - should also remove connection
122 self.graph.remove_node(node1)
123
124 self.assertEqual(len(self.graph.nodes), 1)
125 self.assertEqual(len(self.graph.connections), 0)
126 self.assertNotIn(node1, self.graph.items())
127 self.assertNotIn(connection, self.graph.items())
128
129 def test_connection_creation_and_management(self):
130 """Test creating and managing connections between pins."""

Callers

nothing calls this directly

Calls 4

create_nodeMethod · 0.80
set_codeMethod · 0.80
create_connectionMethod · 0.80
remove_nodeMethod · 0.80

Tested by

no test coverage detected