Skip to content

Commit 0d2954e

Browse files
committed
[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.
1 parent de59979 commit 0d2954e

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-0
lines changed

tests/nodes/test/GroupAttributes.py

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
from meshroom.core import desc
2+
3+
class GroupAttributes(desc.Node):
4+
documentation = """ Test node to connect GroupAttributes to other GroupAttributes. """
5+
category = 'Test'
6+
7+
# Inputs to the node
8+
inputs = [
9+
desc.GroupAttribute(
10+
name="firstGroup",
11+
label="First Group",
12+
description="Group at the root level.",
13+
group=None,
14+
exposed=True,
15+
groupDesc=[
16+
desc.IntParam(
17+
name="firstGroupIntA",
18+
label="Integer A",
19+
description="Integer in group.",
20+
value=1024,
21+
range=(-1, 2000, 10),
22+
exposed=True,
23+
),
24+
desc.IntParam(
25+
name="firstGroupIntB",
26+
label="Integer B",
27+
description="Integer in group.",
28+
value=1024,
29+
range=(-1, 2000, 10),
30+
exposed=True,
31+
),
32+
desc.IntParam(
33+
name="firstGroupIntC",
34+
label="Integer C",
35+
description="Integer in group.",
36+
value=64,
37+
range=(0, 500, 1),
38+
exposed=True,
39+
),
40+
desc.BoolParam(
41+
name="firstGroupBool",
42+
label="Boolean",
43+
description="Boolean in group.",
44+
value=True,
45+
advanced=True,
46+
exposed=True,
47+
),
48+
desc.GroupAttribute(
49+
name="nestedGroup",
50+
label="Nested Group",
51+
description="A group within a group.",
52+
group=None,
53+
exposed=True,
54+
groupDesc=[
55+
desc.FloatParam(
56+
name="nestedGroupFloat",
57+
label="Floating Number",
58+
description="Floating number in group.",
59+
value=1.0,
60+
range=(0.0, 100.0, 0.01),
61+
exposed=True
62+
),
63+
],
64+
),
65+
desc.ListAttribute(
66+
name="groupedList",
67+
label="Grouped List",
68+
description="List of groups within a group.",
69+
advanced=True,
70+
exposed=True,
71+
elementDesc=desc.GroupAttribute(
72+
name="listedGroup",
73+
label="Listed Group",
74+
description="Group in a list within a group.",
75+
joinChar=":",
76+
group=None,
77+
groupDesc=[
78+
desc.ChoiceParam(
79+
name="listedGroupChoice",
80+
label="Choice",
81+
description="Choice attribute in a group in a list within a group.",
82+
value="a",
83+
values=["a", "b", "c", "d"],
84+
exposed=True,
85+
),
86+
desc.FloatParam(
87+
name="listedGroupFloat",
88+
label="Floating Number",
89+
description="Floating number in a group in a list within a group.",
90+
value=2.5,
91+
range=(0.5, 30.0, 0.1),
92+
exposed=True,
93+
),
94+
desc.IntParam(
95+
name="listedGroupInt",
96+
label="Integer 1",
97+
description="Integer in a group in a list within a group.",
98+
value=12,
99+
range=(3, 24, 1),
100+
exposed=True,
101+
),
102+
],
103+
),
104+
),
105+
],
106+
),
107+
desc.IntParam(
108+
name="exposedInt",
109+
label="Exposed Integer",
110+
description="Integer at the rool level, exposed.",
111+
value=1000,
112+
exposed=True,
113+
),
114+
desc.BoolParam(
115+
name="unexposedBool",
116+
label="Unexposed Boolean",
117+
description="Boolean at the root level, unexposed.",
118+
value=True,
119+
),
120+
desc.GroupAttribute(
121+
name="inputGroup",
122+
label="Input Group",
123+
description="A group set as an input.",
124+
group=None,
125+
groupDesc=[
126+
desc.BoolParam(
127+
name="inputBool",
128+
label="Input Bool",
129+
description="",
130+
value=False,
131+
),
132+
],
133+
),
134+
]
135+
136+
outputs = [
137+
desc.GroupAttribute(
138+
name="outputGroup",
139+
label="Output Group",
140+
description="A group set as an output.",
141+
group=None,
142+
exposed=True,
143+
groupDesc=[
144+
desc.BoolParam(
145+
name="outputBool",
146+
label="Output Bool",
147+
description="",
148+
value=False,
149+
exposed=True,
150+
),
151+
],
152+
),
153+
]

tests/test_io.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
4+
import os
5+
import tempfile
6+
7+
from meshroom.core import desc, registerNodeType
8+
from meshroom.core.graph import Graph, loadGraph
9+
from meshroom.core.node import CompatibilityNode
10+
11+
def test_io_group_connections():
12+
"""
13+
Ensure that connecting attributes that are part of GroupAttributes does not cause
14+
their nodes to have CompatibilityIssues when re-opening them.
15+
"""
16+
graph = Graph("Connections between GroupAttributes")
17+
18+
# Create two "GroupAttributes" nodes with their default parameters
19+
nodeA = graph.addNewNode("GroupAttributes")
20+
nodeB = graph.addNewNode("GroupAttributes")
21+
22+
# Connect attributes within groups at different depth levels
23+
graph.addEdges(
24+
(nodeA.firstGroup.firstGroupIntA, nodeB.firstGroup.firstGroupIntA),
25+
(nodeA.firstGroup.nestedGroup.nestedGroupFloat, nodeB.firstGroup.nestedGroup.nestedGroupFloat)
26+
)
27+
28+
# Save the graph in a file
29+
graphFile = os.path.join(tempfile.mkdtemp(), "test_io_group_connections.mg")
30+
graph.save(graphFile)
31+
32+
# Reload the graph
33+
graph = loadGraph(graphFile)
34+
35+
# Ensure the nodes are not CompatibilityNodes
36+
for node in graph.nodes:
37+
assert not isinstance(node, CompatibilityNode)

0 commit comments

Comments
 (0)