Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alicevision/meshroom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCandice Bentéjac <candice.bentejac@gmail.com>2022-10-21 17:20:12 +0300
committerCandice Bentéjac <candice.bentejac@gmail.com>2022-10-21 17:20:12 +0300
commit02f87ff6342177bbd4fbb2dbb6b4401e3e793e88 (patch)
tree5a99c211d27022d99dd82cf20bea6ed7a9195fb8
parentad69c7085e4f7bf225670bead4697794aeb47279 (diff)
[tests] Add a unit test to check for templates' versions
This test checks that there is no compatibility issue with the nodes saved in the template files. It fails when an upgrade of a templates is needed. Any template can still be opened even if its nodes are not up-to- date, as they will be automatically upgraded.
-rw-r--r--tests/test_templatesVersion.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/test_templatesVersion.py b/tests/test_templatesVersion.py
new file mode 100644
index 00000000..784d6728
--- /dev/null
+++ b/tests/test_templatesVersion.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# coding:utf-8
+
+from meshroom.core.graph import Graph
+from meshroom.core import pipelineTemplates, Version
+from meshroom.core.node import CompatibilityIssue, CompatibilityNode
+
+import json
+import meshroom
+
+
+def test_templateVersions():
+ """
+ This test checks that there is no compatibility issue with the nodes saved in the template files.
+ It fails when an upgrade of a templates is needed. Any template can still be opened even if its
+ nodes are not up-to-date, as they will be automatically upgraded.
+ """
+
+ assert len(pipelineTemplates) >= 1
+
+ for _, path in pipelineTemplates.items():
+ with open(path) as jsonFile:
+ fileData = json.load(jsonFile)
+
+ graphData = fileData.get(Graph.IO.Keys.Graph, fileData)
+
+ assert isinstance(graphData, dict)
+
+ header = fileData.get(Graph.IO.Keys.Header, {})
+ assert header.get("template", False)
+ nodesVersions = header.get(Graph.IO.Keys.NodesVersions, {})
+
+ for _, nodeData in graphData.items():
+ nodeType = nodeData["nodeType"]
+ assert nodeType in meshroom.core.nodesDesc
+
+ nodeDesc = meshroom.core.nodesDesc[nodeType]
+ currentNodeVersion = meshroom.core.nodeVersion(nodeDesc)
+
+ inputs = nodeData.get("inputs", {})
+ outputs = nodeData.get("outputs", {})
+ version = nodesVersions.get(nodeType, None)
+
+ compatibilityIssue = None
+
+ if version and currentNodeVersion and Version(version).major != Version(currentNodeVersion).major:
+ compatibilityIssue = CompatibilityIssue.VersionConflict
+ else:
+ for attrName, value in inputs.items():
+ if not CompatibilityNode.attributeDescFromName(nodeDesc.inputs, attrName, value):
+ compatibilityIssue = CompatibilityIssue.DescriptionConflict
+ break
+ for attrName, value in outputs.items():
+ if not CompatibilityNode.attributeDescFromName(nodeDesc.outputs, attrName, value):
+ compatibilityIssue = CompatibilityIssue.DescriptionConflict
+ break
+
+ assert compatibilityIssue is None