def test_findLatestDirInPaths(self): test_folder = tempfile.mkdtemp("test_folder") os.mkdir(os.path.join(test_folder, "whatever")) # There is no folder that matches what we're looking for! assert Resources._findLatestDirInPaths([test_folder]) is None os.mkdir(os.path.join(test_folder, Resources.ApplicationVersion)) # We should obviously find the folder that was created by means of the ApplicationVersion. assert Resources._findLatestDirInPaths([test_folder]) == os.path.join(test_folder, Resources.ApplicationVersion)
def test_findLatestDirInPathsNormalAppVersionEmptySearchFolder(self): test_folder = tempfile.mkdtemp("test_folder") with patch("UM.Resources.Resources.ApplicationVersion", new_callable=PropertyMock(return_value="4.3")): # There is no folder that matches what we're looking for! assert Resources._findLatestDirInPaths([test_folder]) is None
def test_findLatestDirInPathsNormalAppVersionNoValidUpgrade(self): test_folder = tempfile.mkdtemp("test_folder") for folder in ("whatever1", "whatever2", "foobar1", "dev", "master", "test"): os.mkdir(os.path.join(test_folder, folder)) with patch("UM.Resources.Resources.ApplicationVersion", new_callable=PropertyMock(return_value="4.3")): # There is no folder that matches what we're looking for! assert Resources._findLatestDirInPaths([test_folder]) is None
def test_findLatestDirInPathsNormalAppVersion(self): test_folder = tempfile.mkdtemp("test_folder") for folder in ("whatever", "2.1", "3.4", "4.2", "5.1", "10.2", "50.7"): os.mkdir(os.path.join(test_folder, folder)) with patch("UM.Resources.Resources.ApplicationVersion", new_callable=PropertyMock(return_value="4.3")): # We should obviously find the folder that was created by means of the ApplicationVersion. assert Resources._findLatestDirInPaths( [test_folder]) == os.path.join(test_folder, "4.2")