Add test for all built-in profiles being up to date

So we had several hundred files outdated already. It's happened before. It shaln't happen again.

This test fails right now because there is one file still on setting_version 6.

Contributes to issue CURA-7420.
This commit is contained in:
Ghostkeeper 2020-05-08 11:26:37 +02:00
parent 8f9408a76f
commit c61f3b04ba
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,9 +1,11 @@
# Copyright (c) 2019 Ultimaker B.V.
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from unittest.mock import MagicMock
from unittest.mock import MagicMock
import configparser # To read the profiles.
import pytest
from cura.CuraApplication import CuraApplication # To compare against the current SettingVersion.
from UM.Settings.DefinitionContainer import DefinitionContainer
from UM.Settings.InstanceContainer import InstanceContainer
@ -36,7 +38,7 @@ def collectAllSettingIds():
CuraApplication._initializeSettingDefinitions()
definition_container = DefinitionContainer("whatever")
with open(os.path.join(os.path.dirname(__file__), "..", "..", "resources", "definitions", "fdmprinter.def.json"), encoding="utf-8") as data:
with open(os.path.join(os.path.dirname(__file__), "..", "..", "resources", "definitions", "fdmprinter.def.json"), encoding = "utf-8") as data:
definition_container.deserialize(data.read())
return definition_container.getAllKeys()
@ -54,11 +56,11 @@ all_setting_ids = collectAllSettingIds()
variant_filepaths = collectAllVariants()
## Atempt to load all the quality types
## Attempt to load all the quality profiles.
@pytest.mark.parametrize("file_name", quality_filepaths)
def test_validateQualityProfiles(file_name):
try:
with open(file_name, encoding="utf-8") as data:
with open(file_name, encoding = "utf-8") as data:
serialized = data.read()
result = InstanceContainer._readAndValidateSerialized(serialized)
# Fairly obvious, but all the types here should be of the type quality
@ -82,15 +84,15 @@ def test_validateQualityProfiles(file_name):
except Exception as e:
# File can't be read, header sections missing, whatever the case, this shouldn't happen!
print("Got an Exception while reading he file [%s]: %s" % (file_name, e))
print("Got an Exception while reading the file [%s]: %s" % (file_name, e))
assert False
## Attempt to load all the quality types
## Attempt to load all the variant profiles.
@pytest.mark.parametrize("file_name", variant_filepaths)
def test_validateVariantProfiles(file_name):
try:
with open(file_name, encoding="utf-8") as data:
with open(file_name, encoding = "utf-8") as data:
serialized = data.read()
result = InstanceContainer._readAndValidateSerialized(serialized)
# Fairly obvious, but all the types here should be of the type quality
@ -110,5 +112,20 @@ def test_validateVariantProfiles(file_name):
assert False
except Exception as e:
# File can't be read, header sections missing, whatever the case, this shouldn't happen!
print("Got an Exception while reading he file [%s]: %s" % (file_name, e))
print("Got an Exception while reading the file [%s]: %s" % (file_name, e))
assert False
@pytest.mark.parametrize("file_name", quality_filepaths + variant_filepaths)
def test_settingVersionUpToDate(file_name):
try:
with open(file_name, encoding = "utf-8") as data:
parser = configparser.ConfigParser(interpolation = None)
parser.read(file_name)
assert "metadata" in parser
assert "setting_version" in parser["metadata"]
assert int(parser["metadata"]["setting_version"]) == CuraApplication.SettingVersion
except Exception as e:
# File can't be read, header sections missing, whatever the case, this shouldn't happen!
print("Got an exception while reading the file {file_name}: {err}".format(file_name = file_name, err = str(e)))
assert False