Skip to content

Commit e8ae796

Browse files
committed
[tests] Add tests to check that static and command line variables are set
1 parent 2af1deb commit e8ae796

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
__version__ = "1.0"
2+
3+
from meshroom.core import desc
4+
5+
6+
class PluginANodeA(desc.InputNode):
7+
inputs = [
8+
desc.File(
9+
name="input",
10+
label="Input",
11+
description="",
12+
value="",
13+
),
14+
]
15+
16+
outputs = [
17+
desc.File(
18+
name="output",
19+
label="Output",
20+
description="",
21+
value="",
22+
),
23+
]

tests/plugins/meshroom/pluginC/PluginCNodeA.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
class PluginCNodeA(desc.Node):
88
"""PluginCNodeA"""
9-
9+
1010
author = "testAuthor"
11-
11+
1212
inputs = [
1313
desc.File(
1414
name="input",

tests/test_nodes.py

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
from pathlib import Path
66

77
from meshroom.core import pluginManager, loadClassesNodes
8-
from meshroom.core.plugins import Plugin
9-
from meshroom.core import pluginManager
10-
from meshroom.core import pluginManager
118
from meshroom.core.graph import Graph
9+
from meshroom.core.plugins import Plugin
1210

1311
from .utils import registerNodeDesc
1412

@@ -38,17 +36,68 @@ def test_loadedPlugin(self):
3836
assert plugin == self.plugin
3937
node = plugin.nodes["PluginCNodeA"]
4038
nodeType = node.nodeDescriptor
41-
39+
4240
g = Graph("")
4341
registerNodeDesc(nodeType)
4442
node = g.addNewNode(nodeType.__name__)
45-
43+
4644
nodeDocumentation = node.getDocumentation()
4745
assert nodeDocumentation == "PluginCNodeA"
4846
nodeInfos = {item["key"]: item["value"] for item in node.getNodeInfos()}
4947
assert nodeInfos["module"] == "pluginC.PluginCNodeA"
50-
plugin_path = os.path.join(self.folder, "pluginC", "PluginCNodeA.py")
51-
assert nodeInfos["modulePath"] == Path(plugin_path).as_posix() # modulePath seems to follow linux convention
48+
pluginPath = os.path.join(self.folder, "pluginC", "PluginCNodeA.py")
49+
assert nodeInfos["modulePath"] == Path(pluginPath).as_posix() # modulePath seems to follow linux convention
5250
assert nodeInfos["author"] == "testAuthor"
5351
assert nodeInfos["license"] == "no-license"
5452
assert nodeInfos["version"] == "1.0"
53+
54+
55+
class TestNodeVariables:
56+
plugin = None
57+
58+
@classmethod
59+
def setup_class(cls):
60+
folder = os.path.join(os.path.dirname(__file__), "plugins", "meshroom")
61+
package = "pluginA"
62+
cls.plugin = Plugin(package, folder)
63+
nodes = loadClassesNodes(folder, package)
64+
for node in nodes:
65+
cls.plugin.addNodePlugin(node)
66+
pluginManager.addPlugin(cls.plugin)
67+
68+
@classmethod
69+
def teardown_class(cls):
70+
for node in cls.plugin.nodes.values():
71+
pluginManager.unregisterNode(node)
72+
pluginManager.removePlugin(cls.plugin)
73+
cls.plugin = None
74+
75+
def test_staticVariables(self):
76+
g = Graph("")
77+
78+
for nodeName in self.plugin.nodes.keys():
79+
n = g.addNewNode(nodeName)
80+
assert nodeName == n._staticExpVars["nodeType"]
81+
assert n.sourceCodeFolder
82+
assert n.sourceCodeFolder == n._staticExpVars["nodeSourceCodeFolder"]
83+
84+
self.plugin.nodes[nodeName].reload()
85+
86+
assert nodeName == n._staticExpVars["nodeType"]
87+
assert n.sourceCodeFolder
88+
assert n.sourceCodeFolder == n._staticExpVars["nodeSourceCodeFolder"]
89+
90+
def test_expVariables(self):
91+
g = Graph("")
92+
93+
for nodeName in self.plugin.nodes.keys():
94+
n = g.addNewNode(nodeName)
95+
assert n._expVars["uid"] == n._uid
96+
assert n.internalFolder
97+
assert n.internalFolder == n._expVars["nodeCacheFolder"]
98+
99+
self.plugin.nodes[nodeName].reload()
100+
101+
assert n._expVars["uid"] == n._uid
102+
assert n.internalFolder
103+
assert n.internalFolder == n._expVars["nodeCacheFolder"]

0 commit comments

Comments
 (0)