@@ -13,6 +13,32 @@ class SimpleNode(desc.Node):
1313 ]
1414
1515
16+ class NodeWithListAttributes (desc .Node ):
17+ inputs = [
18+ desc .ListAttribute (
19+ name = "listInput" ,
20+ label = "List Input" ,
21+ description = "" ,
22+ elementDesc = desc .File (name = "file" , label = "File" , description = "" , value = "" ),
23+ exposed = True ,
24+ ),
25+ desc .GroupAttribute (
26+ name = "group" ,
27+ label = "Group" ,
28+ description = "" ,
29+ groupDesc = [
30+ desc .ListAttribute (
31+ name = "listInput" ,
32+ label = "List Input" ,
33+ description = "" ,
34+ elementDesc = desc .File (name = "file" , label = "File" , description = "" , value = "" ),
35+ exposed = True ,
36+ ),
37+ ],
38+ ),
39+ ]
40+
41+
1642def compareGraphsContent (graphA : Graph , graphB : Graph ) -> bool :
1743 """Returns whether the content (node and deges) of two graphs are considered identical.
1844
@@ -26,9 +52,10 @@ def _buildNodesSet(graph: Graph):
2652 def _buildEdgesSet (graph : Graph ):
2753 return set ([(edge .src .fullName , edge .dst .fullName ) for edge in graph .edges ])
2854
29- return _buildNodesSet (graphA ) == _buildNodesSet (graphB ) and _buildEdgesSet (graphA ) == _buildEdgesSet (
30- graphB
31- )
55+ nodesSetA , edgesSetA = _buildNodesSet (graphA ), _buildEdgesSet (graphA )
56+ nodesSetB , edgesSetB = _buildNodesSet (graphB ), _buildEdgesSet (graphB )
57+
58+ return nodesSetA == nodesSetB and edgesSetA == edgesSetB
3259
3360
3461class TestImportGraphContent :
@@ -197,7 +224,7 @@ def test_serializeAllNodesIsSimilarToStandardSerialization(self):
197224 assert compareGraphsContent (graph , graphA )
198225 assert compareGraphsContent (graphA , graphB )
199226
200- def test_serializeSingleNodeWithInputConnection (self ):
227+ def test_singleNodeWithInputConnectionFromNonSerializedNodeRemovesEdge (self ):
201228 graph = Graph ("" )
202229
203230 with registeredNodeTypes ([SimpleNode ]):
@@ -215,6 +242,36 @@ def test_serializeSingleNodeWithInputConnection(self):
215242 assert len (otherGraph .nodes ) == 1
216243 assert len (otherGraph .edges ) == 0
217244
245+ def test_serializeSingleNodeWithInputConnectionToListAttributeRemovesListEntry (self ):
246+ graph = Graph ("" )
247+
248+ with registeredNodeTypes ([SimpleNode , NodeWithListAttributes ]):
249+ nodeA = graph .addNewNode (SimpleNode .__name__ )
250+ nodeB = graph .addNewNode (NodeWithListAttributes .__name__ )
251+
252+ nodeB .listInput .append ("" )
253+ graph .addEdge (nodeA .output , nodeB .listInput .at (0 ))
254+
255+ otherGraph = Graph ("" )
256+ otherGraph ._deserialize (graph .serializePartial ([nodeB ]))
257+
258+ assert len (otherGraph .node (nodeB .name ).listInput ) == 0
259+
260+ def test_serializeSingleNodeWithInputConnectionToNestedListAttributeRemovesListEntry (self ):
261+ graph = Graph ("" )
262+
263+ with registeredNodeTypes ([SimpleNode , NodeWithListAttributes ]):
264+ nodeA = graph .addNewNode (SimpleNode .__name__ )
265+ nodeB = graph .addNewNode (NodeWithListAttributes .__name__ )
266+
267+ nodeB .group .listInput .append ("" )
268+ graph .addEdge (nodeA .output , nodeB .group .listInput .at (0 ))
269+
270+ otherGraph = Graph ("" )
271+ otherGraph ._deserialize (graph .serializePartial ([nodeB ]))
272+
273+ assert len (otherGraph .node (nodeB .name ).group .listInput ) == 0
274+
218275
219276class TestGraphCopy :
220277 def test_graphCopyIsIdenticalToOriginalGraph (self ):
@@ -240,4 +297,3 @@ def test_graphCopyWithUnknownNodeTypesDiffersFromOriginalGraph(self):
240297
241298 graphCopy = graph .copy ()
242299 assert not compareGraphsContent (graph , graphCopy )
243-
0 commit comments