|
5 | 5 | from pathlib import Path |
6 | 6 |
|
7 | 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 | 8 | from meshroom.core.graph import Graph |
| 9 | +from meshroom.core.plugins import Plugin |
12 | 10 |
|
13 | 11 | from .utils import registerNodeDesc |
14 | 12 |
|
@@ -38,17 +36,68 @@ def test_loadedPlugin(self): |
38 | 36 | assert plugin == self.plugin |
39 | 37 | node = plugin.nodes["PluginCNodeA"] |
40 | 38 | nodeType = node.nodeDescriptor |
41 | | - |
| 39 | + |
42 | 40 | g = Graph("") |
43 | 41 | registerNodeDesc(nodeType) |
44 | 42 | node = g.addNewNode(nodeType.__name__) |
45 | | - |
| 43 | + |
46 | 44 | nodeDocumentation = node.getDocumentation() |
47 | 45 | assert nodeDocumentation == "PluginCNodeA" |
48 | 46 | nodeInfos = {item["key"]: item["value"] for item in node.getNodeInfos()} |
49 | 47 | 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 |
52 | 50 | assert nodeInfos["author"] == "testAuthor" |
53 | 51 | assert nodeInfos["license"] == "no-license" |
54 | 52 | 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