diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2019-11-06 17:43:43 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2019-11-06 17:43:43 +0300 |
commit | d346dd4090391b34057bf954ebeb1deed682a11a (patch) | |
tree | 45c0e1c10f28d099be19b71232a4d87ce71f4f2b /tests/Settings | |
parent | 33f876d7490342fdfdd150d4c6669f1355158ea7 (diff) |
Fix TestDefinitionContainer
Diffstat (limited to 'tests/Settings')
-rw-r--r-- | tests/Settings/TestDefinitionContainer.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/Settings/TestDefinitionContainer.py b/tests/Settings/TestDefinitionContainer.py index 9e8e967692..38251e4397 100644 --- a/tests/Settings/TestDefinitionContainer.py +++ b/tests/Settings/TestDefinitionContainer.py @@ -3,11 +3,12 @@ import json # To check files for unnecessarily overridden properties. import os -import os.path import pytest #This module contains automated tests. from typing import Any, Dict import uuid +from unittest.mock import patch, MagicMock + import UM.Settings.ContainerRegistry #To create empty instance containers. 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. @@ -24,6 +25,10 @@ definition_filepaths = machine_filepaths + extruder_filepaths all_meshes = os.listdir(os.path.join(os.path.dirname(__file__), "..", "..", "resources", "meshes")) all_images = os.listdir(os.path.join(os.path.dirname(__file__), "..", "..", "resources", "images")) +# Loading definition files needs a functioning ContainerRegistry +cr = UM.Settings.ContainerRegistry.ContainerRegistry(None) + + @pytest.fixture def definition_container(): uid = str(uuid.uuid4()) @@ -39,7 +44,13 @@ def test_validateMachineDefinitionContainer(file_path, definition_container): if file_name == "fdmprinter.def.json" or file_name == "fdmextruder.def.json": return # Stop checking, these are root files. - assertIsDefinitionValid(definition_container, file_path) + from UM.VersionUpgradeManager import FilesDataUpdateResult + + mocked_vum = MagicMock() + mocked_vum.updateFilesData = lambda ct, v, fdl, fnl: FilesDataUpdateResult(ct, v, fdl, fnl) + with patch("UM.VersionUpgradeManager.VersionUpgradeManager.getInstance", MagicMock(return_value = mocked_vum)): + assertIsDefinitionValid(definition_container, file_path) + def assertIsDefinitionValid(definition_container, file_path): with open(file_path, encoding = "utf-8") as data: |