[tests] Update tests to load graphs with strictCompatibility

Update tests that should fail if nodes are loaded as
CompatibilityNodes (resulting in false positives).
This commit is contained in:
Yann Lanthony 2024-11-14 19:11:08 +01:00
parent 3218c41bdc
commit 98f1a9d516

View file

@ -156,7 +156,7 @@ class TestAttributeCallbackTriggerInGraph:
node.affectedInput.value = 2
graph.save()
loadedGraph = loadGraph(graph.filepath)
loadedGraph = loadGraph(graph.filepath, strictCompatibility=True)
loadedNode = loadedGraph.node(node.name)
assert loadedNode
assert loadedNode.affectedInput.value == 2
@ -170,11 +170,13 @@ class TestAttributeCallbackTriggerInGraph:
graph.addEdge(nodeA.input, nodeB.input)
nodeA.input.value = 5
assert nodeB.affectedInput.value == nodeB.input.value * 2
nodeB.affectedInput.value = 2
graph.save()
loadedGraph = loadGraph(graph.filepath)
loadedGraph = loadGraph(graph.filepath, strictCompatibility=True)
loadedNodeB = loadedGraph.node(nodeB.name)
assert loadedNodeB
assert loadedNodeB.affectedInput.value == 2
@ -407,3 +409,25 @@ class TestAttributeCallbackBehaviorWithUpstreamDynamicOutputs:
nodeA.clearData()
assert nodeA.output.value == nodeB.input.value is None
assert nodeB.affectedInput.value == expectedPreClearValue
def test_loadingGraphWithComputedDynamicOutputValueDoesNotTriggerDownstreamAttributeChangedCallback(
self, graphSavedOnDisk
):
graph: Graph = graphSavedOnDisk
nodeA = graph.addNewNode(NodeWithDynamicOutputValue.__name__)
nodeB = graph.addNewNode(NodeWithAttributeChangedCallback.__name__)
nodeA.input.value = 10
graph.addEdge(nodeA.output, nodeB.input)
executeGraph(graph)
assert nodeA.output.value == nodeB.input.value == 20
assert nodeB.affectedInput.value == 0
graph.save()
loadGraph(graph.filepath, strictCompatibility=True)
assert nodeB.affectedInput.value == 0