mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 00:19:01 +08:00
Add test to see if legacy files are renamed
The test seems to fail at the moment. No new file is created. Contributes to issue CURA-3497.
This commit is contained in:
parent
e521f6b38d
commit
053974bc96
@ -3,6 +3,7 @@
|
||||
|
||||
import os #To find the directory with test files and find the test files.
|
||||
import pytest #This module contains unit tests.
|
||||
import shutil #To copy files to make a temporary file.
|
||||
import unittest.mock #To mock and monkeypatch stuff.
|
||||
|
||||
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry #The class we're testing.
|
||||
@ -48,4 +49,25 @@ def test_loadTypes(filename, output_class, container_registry):
|
||||
assert type(container) == output_class
|
||||
break
|
||||
else:
|
||||
assert False #Container stack with specified ID was not loaded.
|
||||
assert False #Container stack with specified ID was not loaded.
|
||||
|
||||
## Tests whether loading a legacy file moves the upgraded file properly.
|
||||
def test_loadLegacyFileRenamed(container_registry):
|
||||
#Create a temporary file for the registry to load.
|
||||
temp_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "stacks", "temporary.stack.cfg")
|
||||
temp_file_source = os.path.join(os.path.dirname(os.path.abspath(__file__)), "stacks", "MachineLegacy.stack.cfg")
|
||||
shutil.copyfile(temp_file_source, temp_file)
|
||||
|
||||
#Mock some dependencies.
|
||||
UM.Settings.ContainerStack.setContainerRegistry(container_registry)
|
||||
Resources.getAllResourcesOfType = unittest.mock.MagicMock(return_value = [temp_file]) #Return a temporary file that we'll make for this test.
|
||||
def findContainers(id, container_type = 0):
|
||||
return [UM.Settings.ContainerRegistry._EmptyInstanceContainer(id)]
|
||||
container_registry.findContainers = findContainers
|
||||
|
||||
with unittest.mock.patch("cura.Settings.GlobalStack.GlobalStack.findContainer"):
|
||||
container_registry.load()
|
||||
|
||||
assert not os.path.isfile(temp_file)
|
||||
new_filename = os.path.splitext(os.path.splitext(temp_file)[0])[0] + ".global.cfg"
|
||||
assert os.path.isfile(new_filename)
|
Loading…
x
Reference in New Issue
Block a user