TestVersionUpgrade34to35.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. import configparser #To parse the resulting config files.
  4. import pytest #To register tests with.
  5. import VersionUpgrade34to35 #The module we're testing.
  6. ## Creates an instance of the upgrader to test with.
  7. @pytest.fixture
  8. def upgrader():
  9. return VersionUpgrade34to35.VersionUpgrade34to35()
  10. test_upgrade_version_nr_data = [
  11. ("Empty config file",
  12. """[general]
  13. version = 5
  14. [metadata]
  15. setting_version = 4
  16. [info]
  17. asked_send_slice_info = True
  18. send_slice_info = True
  19. """
  20. )
  21. ]
  22. ## Tests whether the version numbers are updated.
  23. @pytest.mark.parametrize("test_name, file_data", test_upgrade_version_nr_data)
  24. def test_upgradeVersionNr(test_name, file_data, upgrader):
  25. #Perform the upgrade.
  26. _, upgraded_instances = upgrader.upgradePreferences(file_data, "<string>")
  27. upgraded_instance = upgraded_instances[0]
  28. parser = configparser.ConfigParser(interpolation = None)
  29. parser.read_string(upgraded_instance)
  30. #Check the new version.
  31. assert parser["general"]["version"] == "6"
  32. assert parser["metadata"]["setting_version"] == "5"
  33. # Check if the data collection values have been reset to their defaults
  34. assert parser.get("info", "asked_send_slice_info") == "False"
  35. assert parser.get("info", "send_slice_info") == "True"