mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-04 11:51:58 +02:00
[tests] add tests on graph invalidation
This commit is contained in:
parent
f051148d7a
commit
3b45ac1669
1 changed files with 47 additions and 0 deletions
47
tests/test_invalidation.py
Normal file
47
tests/test_invalidation.py
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# coding:utf-8
|
||||||
|
from meshroom.core.graph import Graph
|
||||||
|
from meshroom.core import desc, registerNodeType
|
||||||
|
|
||||||
|
|
||||||
|
class SampleNode(desc.Node):
|
||||||
|
""" Sample Node for unit testing """
|
||||||
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
|
input = desc.File(label='Input', description='', value='', uid=[0], isOutput=False)
|
||||||
|
output = desc.File(label='Output', description='', value='{cache}/{nodeType}/{uid0}/', uid=[], isOutput=True)
|
||||||
|
# No impact on UID
|
||||||
|
paramA = desc.StringParam(label='ParamA', description='', value='', uid=[])
|
||||||
|
|
||||||
|
|
||||||
|
registerNodeType(SampleNode)
|
||||||
|
|
||||||
|
|
||||||
|
def test_output_invalidation():
|
||||||
|
graph = Graph('')
|
||||||
|
n1 = graph.addNewNode('SampleNode', input='/tmp')
|
||||||
|
n2 = graph.addNewNode('SampleNode')
|
||||||
|
n3 = graph.addNewNode('SampleNode')
|
||||||
|
|
||||||
|
graph.addEdges(
|
||||||
|
(n1.output, n2.input),
|
||||||
|
(n1.output, n3.input)
|
||||||
|
)
|
||||||
|
|
||||||
|
# N1.output ----- N2.input
|
||||||
|
# \
|
||||||
|
# N3.input
|
||||||
|
|
||||||
|
# Compare UIDs of similar attributes on different nodes
|
||||||
|
n2inputUid = n2.input.uid()
|
||||||
|
n3inputUid = n3.input.uid()
|
||||||
|
assert n3inputUid == n2inputUid # => UIDs are equal
|
||||||
|
|
||||||
|
# Change a parameter outside UID
|
||||||
|
n1.paramA.value = 'a'
|
||||||
|
assert n2.input.uid() == n2inputUid # => same UID as before
|
||||||
|
|
||||||
|
# Change a parameter impacting UID
|
||||||
|
n1.input.value = "/a/path"
|
||||||
|
assert n2.input.uid() != n2inputUid # => UID has changed
|
||||||
|
assert n2.input.uid() == n3.input.uid() # => UIDs on both node are still equal
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue