mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-20 21:27:50 -06:00
Some minor stylechanges in tests
This commit is contained in:
parent
ea0c8ff9bc
commit
cb657ac45a
1 changed files with 9 additions and 4 deletions
|
@ -12,7 +12,7 @@ from unittest.mock import patch, MagicMock
|
||||||
import UM.Settings.ContainerRegistry #To create empty instance containers.
|
import UM.Settings.ContainerRegistry #To create empty instance containers.
|
||||||
import UM.Settings.ContainerStack #To set the container registry the container stacks use.
|
import UM.Settings.ContainerStack #To set the container registry the container stacks use.
|
||||||
from UM.Settings.DefinitionContainer import DefinitionContainer #To check against the class of DefinitionContainer.
|
from UM.Settings.DefinitionContainer import DefinitionContainer #To check against the class of DefinitionContainer.
|
||||||
|
from UM.VersionUpgradeManager import FilesDataUpdateResult
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
Resources.addSearchPath(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "resources")))
|
Resources.addSearchPath(os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "resources")))
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ def definition_container():
|
||||||
assert result.getId() == uid
|
assert result.getId() == uid
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("file_path", definition_filepaths)
|
@pytest.mark.parametrize("file_path", definition_filepaths)
|
||||||
def test_definitionIds(file_path):
|
def test_definitionIds(file_path):
|
||||||
"""
|
"""
|
||||||
|
@ -45,6 +46,7 @@ def test_definitionIds(file_path):
|
||||||
definition_id = os.path.basename(file_path).split(".")[0]
|
definition_id = os.path.basename(file_path).split(".")[0]
|
||||||
assert " " not in definition_id # Definition IDs are not allowed to have spaces.
|
assert " " not in definition_id # Definition IDs are not allowed to have spaces.
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("file_path", definition_filepaths)
|
@pytest.mark.parametrize("file_path", definition_filepaths)
|
||||||
def test_noCategory(file_path):
|
def test_noCategory(file_path):
|
||||||
"""
|
"""
|
||||||
|
@ -57,6 +59,7 @@ def test_noCategory(file_path):
|
||||||
metadata = DefinitionContainer.deserializeMetadata(json, "test_container_id")
|
metadata = DefinitionContainer.deserializeMetadata(json, "test_container_id")
|
||||||
assert "category" not in metadata[0]
|
assert "category" not in metadata[0]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("file_path", machine_filepaths)
|
@pytest.mark.parametrize("file_path", machine_filepaths)
|
||||||
def test_validateMachineDefinitionContainer(file_path, definition_container):
|
def test_validateMachineDefinitionContainer(file_path, definition_container):
|
||||||
"""Tests all definition containers"""
|
"""Tests all definition containers"""
|
||||||
|
@ -65,13 +68,12 @@ def test_validateMachineDefinitionContainer(file_path, definition_container):
|
||||||
if file_name == "fdmprinter.def.json" or file_name == "fdmextruder.def.json":
|
if file_name == "fdmprinter.def.json" or file_name == "fdmextruder.def.json":
|
||||||
return # Stop checking, these are root files.
|
return # Stop checking, these are root files.
|
||||||
|
|
||||||
from UM.VersionUpgradeManager import FilesDataUpdateResult
|
|
||||||
|
|
||||||
mocked_vum = MagicMock()
|
mocked_vum = MagicMock()
|
||||||
mocked_vum.updateFilesData = lambda ct, v, fdl, fnl: FilesDataUpdateResult(ct, v, fdl, fnl)
|
mocked_vum.updateFilesData = lambda ct, v, fdl, fnl: FilesDataUpdateResult(ct, v, fdl, fnl)
|
||||||
with patch("UM.VersionUpgradeManager.VersionUpgradeManager.getInstance", MagicMock(return_value = mocked_vum)):
|
with patch("UM.VersionUpgradeManager.VersionUpgradeManager.getInstance", MagicMock(return_value = mocked_vum)):
|
||||||
assertIsDefinitionValid(definition_container, file_path)
|
assertIsDefinitionValid(definition_container, file_path)
|
||||||
|
|
||||||
|
|
||||||
def assertIsDefinitionValid(definition_container, file_path):
|
def assertIsDefinitionValid(definition_container, file_path):
|
||||||
with open(file_path, encoding = "utf-8") as data:
|
with open(file_path, encoding = "utf-8") as data:
|
||||||
json = data.read()
|
json = data.read()
|
||||||
|
@ -86,6 +88,7 @@ def assertIsDefinitionValid(definition_container, file_path):
|
||||||
if "platform_texture" in metadata[0]:
|
if "platform_texture" in metadata[0]:
|
||||||
assert metadata[0]["platform_texture"] in all_images
|
assert metadata[0]["platform_texture"] in all_images
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("file_path", definition_filepaths)
|
@pytest.mark.parametrize("file_path", definition_filepaths)
|
||||||
def test_validateOverridingDefaultValue(file_path: str):
|
def test_validateOverridingDefaultValue(file_path: str):
|
||||||
"""Tests whether setting values are not being hidden by parent containers.
|
"""Tests whether setting values are not being hidden by parent containers.
|
||||||
|
@ -189,7 +192,9 @@ def test_noId(file_path: str):
|
||||||
|
|
||||||
@pytest.mark.parametrize("file_path", extruder_filepaths)
|
@pytest.mark.parametrize("file_path", extruder_filepaths)
|
||||||
def test_extruderMatch(file_path: str):
|
def test_extruderMatch(file_path: str):
|
||||||
"""Verifies that extruders say that they work on the same extruder_nr as what is listed in their machine definition."""
|
"""
|
||||||
|
Verifies that extruders say that they work on the same extruder_nr as what is listed in their machine definition.
|
||||||
|
"""
|
||||||
|
|
||||||
extruder_id = os.path.basename(file_path).split(".")[0]
|
extruder_id = os.path.basename(file_path).split(".")[0]
|
||||||
with open(file_path, encoding = "utf-8") as f:
|
with open(file_path, encoding = "utf-8") as f:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue