Skip to content

Commit bbdf2d2

Browse files
committed
[tests] Update tests to load graphs with strictCompatibility
Update tests that should fail if nodes are loaded as CompatibilityNodes (resulting in false positives).
1 parent 412103a commit bbdf2d2

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

tests/test_nodeAttributeChangedCallback.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def test_loadingGraphDoesNotTriggerCallback(self, graphSavedOnDisk):
156156
node.affectedInput.value = 2
157157
graph.save()
158158

159-
loadedGraph = loadGraph(graph.filepath)
159+
loadedGraph = loadGraph(graph.filepath, strictCompatibility=True)
160160
loadedNode = loadedGraph.node(node.name)
161161
assert loadedNode
162162
assert loadedNode.affectedInput.value == 2
@@ -170,11 +170,13 @@ def test_loadingGraphDoesNotTriggerCallbackForConnectedAttributes(
170170

171171
graph.addEdge(nodeA.input, nodeB.input)
172172
nodeA.input.value = 5
173+
assert nodeB.affectedInput.value == nodeB.input.value * 2
174+
173175
nodeB.affectedInput.value = 2
174176

175177
graph.save()
176178

177-
loadedGraph = loadGraph(graph.filepath)
179+
loadedGraph = loadGraph(graph.filepath, strictCompatibility=True)
178180
loadedNodeB = loadedGraph.node(nodeB.name)
179181
assert loadedNodeB
180182
assert loadedNodeB.affectedInput.value == 2
@@ -407,3 +409,25 @@ def test_clearingDynamicOutputValueDoesNotTriggerDownstreamAttributeChangedCallb
407409
nodeA.clearData()
408410
assert nodeA.output.value == nodeB.input.value is None
409411
assert nodeB.affectedInput.value == expectedPreClearValue
412+
413+
def test_loadingGraphWithComputedDynamicOutputValueDoesNotTriggerDownstreamAttributeChangedCallback(
414+
self, graphSavedOnDisk
415+
):
416+
graph: Graph = graphSavedOnDisk
417+
nodeA = graph.addNewNode(NodeWithDynamicOutputValue.__name__)
418+
nodeB = graph.addNewNode(NodeWithAttributeChangedCallback.__name__)
419+
420+
nodeA.input.value = 10
421+
graph.addEdge(nodeA.output, nodeB.input)
422+
executeGraph(graph)
423+
424+
assert nodeA.output.value == nodeB.input.value == 20
425+
assert nodeB.affectedInput.value == 0
426+
427+
graph.save()
428+
429+
loadGraph(graph.filepath, strictCompatibility=True)
430+
431+
assert nodeB.affectedInput.value == 0
432+
433+

0 commit comments

Comments
 (0)