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

test_templatesVersion.py « tests - github.com/alicevision/meshroom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3d391ecf938b79f8a5cb8eab598a88ada3032c1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/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", {})
            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

            assert compatibilityIssue is None