Skip to content

Commit 41765b8

Browse files
committed
[tests] Add tests for the node documentation and infos
1 parent 95c9c45 commit 41765b8

File tree

3 files changed

+82
-0
lines changed

3 files changed

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

tests/plugins/meshroom/pluginC/__init__.py

Whitespace-only changes.

tests/test_nodes.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
4+
import os
5+
from pathlib import Path
6+
7+
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
11+
from meshroom.core.graph import Graph
12+
13+
from .utils import registerNodeDesc
14+
15+
16+
class TestNodeInfos:
17+
plugin = None
18+
19+
@classmethod
20+
def setup_class(cls):
21+
cls.folder = os.path.join(os.path.dirname(__file__), "plugins", "meshroom")
22+
package = "pluginC"
23+
cls.plugin = Plugin(package, cls.folder)
24+
nodes = loadClassesNodes(cls.folder, package)
25+
for node in nodes:
26+
cls.plugin.addNodePlugin(node)
27+
pluginManager.addPlugin(cls.plugin)
28+
29+
@classmethod
30+
def teardown_class(cls):
31+
for node in cls.plugin.nodes.values():
32+
pluginManager.unregisterNode(node)
33+
cls.plugin = None
34+
35+
def test_loadedPlugin(self):
36+
assert len(pluginManager.getPlugins()) >= 1
37+
plugin = pluginManager.getPlugin("pluginC")
38+
assert plugin == self.plugin
39+
node = plugin.nodes["PluginCNodeA"]
40+
nodeType = node.nodeDescriptor
41+
42+
g = Graph("")
43+
registerNodeDesc(nodeType)
44+
node = g.addNewNode(nodeType.__name__)
45+
46+
nodeDocumentation = node.getDocumentation()
47+
assert nodeDocumentation == "PluginCNodeA"
48+
nodeInfos = {item["key"]: item["value"] for item in node.getNodeInfos()}
49+
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
52+
assert nodeInfos["author"] == "testAuthor"
53+
assert nodeInfos["license"] == "no-license"
54+
assert nodeInfos["version"] == "1.0"

0 commit comments

Comments
 (0)