mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 00:45:55 +08:00
Fix tests for ContainerManager
CURA-6600
This commit is contained in:
parent
719e69692c
commit
e18820b846
@ -143,7 +143,6 @@ class IntentManager(QObject):
|
|||||||
extruder_stack.intent = intent[0]
|
extruder_stack.intent = intent[0]
|
||||||
else:
|
else:
|
||||||
extruder_stack.intent = self.getDefaultIntent()
|
extruder_stack.intent = self.getDefaultIntent()
|
||||||
|
|
||||||
application.getMachineManager().setQualityGroupByQualityType(quality_type)
|
application.getMachineManager().setQualityGroupByQualityType(quality_type)
|
||||||
if old_intent_category != intent_category:
|
if old_intent_category != intent_category:
|
||||||
self.intentCategoryChanged.emit()
|
self.intentCategoryChanged.emit()
|
||||||
|
@ -2,7 +2,7 @@ from unittest import TestCase
|
|||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from PyQt5.QtCore import QUrl
|
from PyQt5.QtCore import QUrl
|
||||||
|
from unittest.mock import patch
|
||||||
from UM.MimeTypeDatabase import MimeTypeDatabase
|
from UM.MimeTypeDatabase import MimeTypeDatabase
|
||||||
from cura.Settings.ContainerManager import ContainerManager
|
from cura.Settings.ContainerManager import ContainerManager
|
||||||
import tempfile
|
import tempfile
|
||||||
@ -42,14 +42,17 @@ class TestContainerManager(TestCase):
|
|||||||
MimeTypeDatabase.removeMimeType(self._mocked_mime)
|
MimeTypeDatabase.removeMimeType(self._mocked_mime)
|
||||||
|
|
||||||
def test_getContainerMetaDataEntry(self):
|
def test_getContainerMetaDataEntry(self):
|
||||||
|
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=self._application)):
|
||||||
assert self._container_manager.getContainerMetaDataEntry("test", "test_data") == "omg"
|
assert self._container_manager.getContainerMetaDataEntry("test", "test_data") == "omg"
|
||||||
assert self._container_manager.getContainerMetaDataEntry("test", "entry_that_is_not_defined") == ""
|
assert self._container_manager.getContainerMetaDataEntry("test", "entry_that_is_not_defined") == ""
|
||||||
|
|
||||||
def test_clearUserContainer(self):
|
def test_clearUserContainer(self):
|
||||||
|
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=self._application)):
|
||||||
self._container_manager.clearUserContainers()
|
self._container_manager.clearUserContainers()
|
||||||
assert self._machine_manager.activeMachine.userChanges.clear.call_count == 1
|
assert self._machine_manager.activeMachine.userChanges.clear.call_count == 1
|
||||||
|
|
||||||
def test_getContainerNameFilters(self):
|
def test_getContainerNameFilters(self):
|
||||||
|
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=self._application)):
|
||||||
# If nothing is added, we still expect to get the all files filter
|
# If nothing is added, we still expect to get the all files filter
|
||||||
assert self._container_manager.getContainerNameFilters("") == ['All Files (*)']
|
assert self._container_manager.getContainerNameFilters("") == ['All Files (*)']
|
||||||
|
|
||||||
@ -69,6 +72,7 @@ class TestContainerManager(TestCase):
|
|||||||
assert self._container_manager.exportContainer("", "whatever", "whatever")["status"] == "error"
|
assert self._container_manager.exportContainer("", "whatever", "whatever")["status"] == "error"
|
||||||
|
|
||||||
def test_exportContainer(self):
|
def test_exportContainer(self):
|
||||||
|
with patch("cura.CuraApplication.CuraApplication.getInstance", MagicMock(return_value=self._application)):
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
result = self._container_manager.exportContainer("test", "whatever", os.path.join(tmpdirname, "whatever.omg"))
|
result = self._container_manager.exportContainer("test", "whatever", os.path.join(tmpdirname, "whatever.omg"))
|
||||||
assert(os.path.exists(result["path"]))
|
assert(os.path.exists(result["path"]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user