mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Add some tests for DFProjectModel
CURA-7959
This commit is contained in:
parent
7979483e48
commit
29f62b0579
2 changed files with 61 additions and 1 deletions
|
@ -21,7 +21,7 @@ class DigitalFactoryProjectModel(ListModel):
|
||||||
|
|
||||||
dfProjectModelChanged = pyqtSignal()
|
dfProjectModelChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.addRoleName(self.DisplayNameRole, "displayName")
|
self.addRoleName(self.DisplayNameRole, "displayName")
|
||||||
self.addRoleName(self.LibraryProjectIdRole, "libraryProjectId")
|
self.addRoleName(self.LibraryProjectIdRole, "libraryProjectId")
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
|
||||||
|
from src.DigitalFactoryProjectModel import DigitalFactoryProjectModel
|
||||||
|
from src.DigitalFactoryProjectResponse import DigitalFactoryProjectResponse
|
||||||
|
|
||||||
|
|
||||||
|
project_1 = DigitalFactoryProjectResponse(library_project_id = "omg",
|
||||||
|
display_name = "zomg",
|
||||||
|
username = "nope",
|
||||||
|
organization_shared = True)
|
||||||
|
|
||||||
|
project_2 = DigitalFactoryProjectResponse(library_project_id = "omg2",
|
||||||
|
display_name = "zomg2",
|
||||||
|
username = "nope",
|
||||||
|
organization_shared = False)
|
||||||
|
|
||||||
|
project_3 = DigitalFactoryProjectResponse(library_project_id = "_omg3",
|
||||||
|
display_name = "zomg3",
|
||||||
|
username = "nope",
|
||||||
|
organization_shared = False)
|
||||||
|
|
||||||
|
|
||||||
|
def test_setProjects():
|
||||||
|
model = DigitalFactoryProjectModel()
|
||||||
|
|
||||||
|
assert model.count == 0
|
||||||
|
|
||||||
|
model.setProjects([project_1, project_2])
|
||||||
|
assert model.count == 2
|
||||||
|
|
||||||
|
assert model.getItem(0)["displayName"] == "zomg"
|
||||||
|
assert model.getItem(1)["displayName"] == "zomg2"
|
||||||
|
|
||||||
|
|
||||||
|
def test_clearProjects():
|
||||||
|
model = DigitalFactoryProjectModel()
|
||||||
|
model.setProjects([project_1, project_2])
|
||||||
|
model.clearProjects()
|
||||||
|
assert model.count == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_setProjectMultipleTimes():
|
||||||
|
model = DigitalFactoryProjectModel()
|
||||||
|
model.setProjects([project_1, project_2])
|
||||||
|
model.setProjects([project_2])
|
||||||
|
assert model.count == 1
|
||||||
|
assert model.getItem(0)["displayName"] == "zomg2"
|
||||||
|
|
||||||
|
|
||||||
|
def test_extendProjects():
|
||||||
|
model = DigitalFactoryProjectModel()
|
||||||
|
|
||||||
|
assert model.count == 0
|
||||||
|
|
||||||
|
model.setProjects([project_1])
|
||||||
|
assert model.count == 1
|
||||||
|
|
||||||
|
model.extendProjects([project_2])
|
||||||
|
assert model.count == 2
|
||||||
|
assert model.getItem(0)["displayName"] == "zomg"
|
||||||
|
assert model.getItem(1)["displayName"] == "zomg2"
|
Loading…
Add table
Add a link
Reference in a new issue