mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 05:53:59 -06:00
Add test for global stack getting user changes
Tests fail right now because running the test actually deletes files. Got to fix that. Contributes to issue CURA-3497.
This commit is contained in:
parent
c5768d89dc
commit
49fad35d28
7 changed files with 50 additions and 7 deletions
|
@ -11,6 +11,7 @@ from cura.Settings.GlobalStack import GlobalStack #Testing for returning the cor
|
|||
from UM.Resources import Resources #Mocking some functions of this.
|
||||
import UM.Settings.ContainerRegistry #Making empty container stacks.
|
||||
import UM.Settings.ContainerStack #Setting the container registry here properly.
|
||||
from UM.Settings.DefinitionContainer import DefinitionContainer #Checking against the DefinitionContainer class.
|
||||
|
||||
## Gives a fresh CuraContainerRegistry instance.
|
||||
@pytest.fixture()
|
||||
|
@ -30,13 +31,17 @@ def test_loadTypes(filename, output_class, container_registry):
|
|||
UM.Settings.ContainerStack.setContainerRegistry(container_registry)
|
||||
Resources.getAllResourcesOfType = unittest.mock.MagicMock(return_value = [os.path.join(os.path.dirname(os.path.abspath(__file__)), "stacks", filename)]) #Return just this tested file.
|
||||
def findContainers(id, container_type = 0):
|
||||
if id == "empty_material":
|
||||
if id == "some_material" or id == "some_definition":
|
||||
return [UM.Settings.ContainerRegistry._EmptyInstanceContainer(id)]
|
||||
else:
|
||||
return []
|
||||
container_registry.findContainers = findContainers
|
||||
mock_definition = unittest.mock.MagicMock()
|
||||
def findContainer(container_id = "*", container_type = None, type = "*", category = None):
|
||||
return unittest.mock.MagicMock()
|
||||
|
||||
container_registry.load()
|
||||
with unittest.mock.patch("cura.Settings.GlobalStack.GlobalStack.findContainer", findContainer):
|
||||
container_registry.load()
|
||||
|
||||
#Check whether the resulting type was correct.
|
||||
stack_id = filename.split(".")[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue