-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] Add test node with
GroupAttributes
and unit test
The test ensures that if the attributes within `GroupAttributes` are connected to each other, the graph can be saved and reloaded without triggering compatibility issues for these nodes.
- Loading branch information
Showing
2 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
from meshroom.core import desc | ||
|
||
class GroupAttributes(desc.Node): | ||
documentation = """ Test node to connect GroupAttributes to other GroupAttributes. """ | ||
category = 'Test' | ||
|
||
# Inputs to the node | ||
inputs = [ | ||
desc.GroupAttribute( | ||
name="firstGroup", | ||
label="First Group", | ||
description="Group at the root level.", | ||
group=None, | ||
exposed=True, | ||
groupDesc=[ | ||
desc.IntParam( | ||
name="firstGroupIntA", | ||
label="Integer A", | ||
description="Integer in group.", | ||
value=1024, | ||
range=(-1, 2000, 10), | ||
exposed=True, | ||
), | ||
desc.IntParam( | ||
name="firstGroupIntB", | ||
label="Integer B", | ||
description="Integer in group.", | ||
value=1024, | ||
range=(-1, 2000, 10), | ||
exposed=True, | ||
), | ||
desc.IntParam( | ||
name="firstGroupIntC", | ||
label="Integer C", | ||
description="Integer in group.", | ||
value=64, | ||
range=(0, 500, 1), | ||
exposed=True, | ||
), | ||
desc.BoolParam( | ||
name="firstGroupBool", | ||
label="Boolean", | ||
description="Boolean in group.", | ||
value=True, | ||
advanced=True, | ||
exposed=True, | ||
), | ||
desc.GroupAttribute( | ||
name="nestedGroup", | ||
label="Nested Group", | ||
description="A group within a group.", | ||
group=None, | ||
exposed=True, | ||
groupDesc=[ | ||
desc.FloatParam( | ||
name="nestedGroupFloat", | ||
label="Floating Number", | ||
description="Floating number in group.", | ||
value=1.0, | ||
range=(0.0, 100.0, 0.01), | ||
exposed=True | ||
), | ||
], | ||
), | ||
desc.ListAttribute( | ||
name="groupedList", | ||
label="Grouped List", | ||
description="List of groups within a group.", | ||
advanced=True, | ||
exposed=True, | ||
elementDesc=desc.GroupAttribute( | ||
name="listedGroup", | ||
label="Listed Group", | ||
description="Group in a list within a group.", | ||
joinChar=":", | ||
group=None, | ||
groupDesc=[ | ||
desc.ChoiceParam( | ||
name="listedGroupChoice", | ||
label="Choice", | ||
description="Choice attribute in a group in a list within a group.", | ||
value="a", | ||
values=["a", "b", "c", "d"], | ||
exposed=True, | ||
), | ||
desc.FloatParam( | ||
name="listedGroupFloat", | ||
label="Floating Number", | ||
description="Floating number in a group in a list within a group.", | ||
value=2.5, | ||
range=(0.5, 30.0, 0.1), | ||
exposed=True, | ||
), | ||
desc.IntParam( | ||
name="listedGroupInt", | ||
label="Integer 1", | ||
description="Integer in a group in a list within a group.", | ||
value=12, | ||
range=(3, 24, 1), | ||
exposed=True, | ||
), | ||
], | ||
), | ||
), | ||
], | ||
), | ||
desc.IntParam( | ||
name="exposedInt", | ||
label="Exposed Integer", | ||
description="Integer at the rool level, exposed.", | ||
value=1000, | ||
exposed=True, | ||
), | ||
desc.BoolParam( | ||
name="unexposedBool", | ||
label="Unexposed Boolean", | ||
description="Boolean at the root level, unexposed.", | ||
value=True, | ||
), | ||
desc.GroupAttribute( | ||
name="inputGroup", | ||
label="Input Group", | ||
description="A group set as an input.", | ||
group=None, | ||
groupDesc=[ | ||
desc.BoolParam( | ||
name="inputBool", | ||
label="Input Bool", | ||
description="", | ||
value=False, | ||
), | ||
], | ||
), | ||
] | ||
|
||
outputs = [ | ||
desc.GroupAttribute( | ||
name="outputGroup", | ||
label="Output Group", | ||
description="A group set as an output.", | ||
group=None, | ||
exposed=True, | ||
groupDesc=[ | ||
desc.BoolParam( | ||
name="outputBool", | ||
label="Output Bool", | ||
description="", | ||
value=False, | ||
exposed=True, | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
# coding:utf-8 | ||
|
||
import os | ||
import tempfile | ||
|
||
from meshroom.core import desc, registerNodeType | ||
from meshroom.core.graph import Graph, loadGraph | ||
from meshroom.core.node import CompatibilityNode | ||
|
||
def test_io_group_connections(): | ||
""" | ||
Ensure that connecting attributes that are part of GroupAttributes does not cause | ||
their nodes to have CompatibilityIssues when re-opening them. | ||
""" | ||
graph = Graph("Connections between GroupAttributes") | ||
|
||
# Create two "GroupAttributes" nodes with their default parameters | ||
nodeA = graph.addNewNode("GroupAttributes") | ||
nodeB = graph.addNewNode("GroupAttributes") | ||
|
||
# Connect attributes within groups at different depth levels | ||
graph.addEdges( | ||
(nodeA.firstGroup.firstGroupIntA, nodeB.firstGroup.firstGroupIntA), | ||
(nodeA.firstGroup.nestedGroup.nestedGroupFloat, nodeB.firstGroup.nestedGroup.nestedGroupFloat) | ||
) | ||
|
||
# Save the graph in a file | ||
graphFile = os.path.join(tempfile.mkdtemp(), "test_io_group_connections.mg") | ||
graph.save(graphFile) | ||
|
||
# Reload the graph | ||
graph = loadGraph(graphFile) | ||
|
||
# Ensure the nodes are not CompatibilityNodes | ||
for node in graph.nodes: | ||
assert not isinstance(node, CompatibilityNode) |