TestDigitalFactoryProjectModel.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from src.DigitalFactoryProjectModel import DigitalFactoryProjectModel
  2. from src.DigitalFactoryProjectResponse import DigitalFactoryProjectResponse
  3. project_1 = DigitalFactoryProjectResponse(library_project_id = "omg",
  4. display_name = "zomg",
  5. username = "nope",
  6. organization_shared = True)
  7. project_2 = DigitalFactoryProjectResponse(library_project_id = "omg2",
  8. display_name = "zomg2",
  9. username = "nope",
  10. organization_shared = False)
  11. def test_setProjects():
  12. model = DigitalFactoryProjectModel()
  13. assert model.count == 0
  14. model.setProjects([project_1, project_2])
  15. assert model.count == 2
  16. assert model.getItem(0)["displayName"] == "zomg"
  17. assert model.getItem(1)["displayName"] == "zomg2"
  18. def test_clearProjects():
  19. model = DigitalFactoryProjectModel()
  20. model.setProjects([project_1, project_2])
  21. model.clearProjects()
  22. assert model.count == 0
  23. def test_setProjectMultipleTimes():
  24. model = DigitalFactoryProjectModel()
  25. model.setProjects([project_1, project_2])
  26. model.setProjects([project_2])
  27. assert model.count == 1
  28. assert model.getItem(0)["displayName"] == "zomg2"
  29. def test_extendProjects():
  30. model = DigitalFactoryProjectModel()
  31. assert model.count == 0
  32. model.setProjects([project_1])
  33. assert model.count == 1
  34. model.extendProjects([project_2])
  35. assert model.count == 2
  36. assert model.getItem(0)["displayName"] == "zomg"
  37. assert model.getItem(1)["displayName"] == "zomg2"