|
| 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