Merge branch 'small-fixes' into 'master'

Some small fixes

See merge request openlp/openlp!79
This commit is contained in:
Raoul Snyman 2019-11-20 18:52:17 +00:00
commit 3ab4c4533b
3 changed files with 15 additions and 13 deletions

View File

@ -61,13 +61,14 @@ class AppLocation(object):
:rtype: Path
"""
if dir_type == AppLocation.AppDir or dir_type == AppLocation.VersionDir:
return get_frozen_path(FROZEN_APP_PATH, APP_PATH)
path = get_frozen_path(FROZEN_APP_PATH, APP_PATH)
elif dir_type == AppLocation.PluginsDir:
return get_frozen_path(FROZEN_APP_PATH, APP_PATH) / 'plugins'
path = get_frozen_path(FROZEN_APP_PATH, APP_PATH) / 'plugins'
elif dir_type == AppLocation.LanguageDir:
return get_frozen_path(FROZEN_APP_PATH, _get_os_dir_path(dir_type)) / 'i18n'
path = get_frozen_path(FROZEN_APP_PATH, _get_os_dir_path(dir_type)) / 'i18n'
else:
return _get_os_dir_path(dir_type)
path = _get_os_dir_path(dir_type)
return path.resolve()
@staticmethod
def get_data_path():
@ -83,7 +84,7 @@ class AppLocation(object):
else:
path = AppLocation.get_directory(AppLocation.DataDir)
create_paths(path)
return path
return path.resolve()
@staticmethod
def get_files(section=None, extension=''):

View File

@ -554,7 +554,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow, LogMixin, RegistryPropert
wait_dialog.setAutoClose(False)
wait_dialog.setCancelButton(None)
wait_dialog.show()
thread_names = self.application.worker_threads.keys()
thread_names = list(self.application.worker_threads.keys())
for thread_name in thread_names:
if thread_name not in self.application.worker_threads.keys():
continue

View File

@ -30,6 +30,7 @@ from openlp.core.common.applocation import AppLocation
FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3']
BASE_DIR = (AppLocation.get_directory(AppLocation.AppDir) / '..').resolve()
@patch('openlp.core.common.applocation.Settings')
@ -42,9 +43,9 @@ def test_get_data_path(mocked_os, mocked_create_paths, mocked_get_directory, Moc
"""
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
MockSettings.return_value.contains.return_value = False
mocked_get_directory.return_value = os.path.join('tests', 'dir')
mocked_get_directory.return_value = Path('tests', 'dir')
mocked_create_paths.return_value = True
mocked_os.path.normpath.return_value = os.path.join('tests', 'dir')
mocked_os.path.normpath.return_value = Path('tests', 'dir')
# WHEN: we call AppLocation.get_data_path()
data_path = AppLocation.get_data_path()
@ -52,8 +53,8 @@ def test_get_data_path(mocked_os, mocked_create_paths, mocked_get_directory, Moc
# THEN: check that all the correct methods were called, and the result is correct
MockSettings.return_value.contains.assert_called_with('advanced/data path')
mocked_get_directory.assert_called_with(AppLocation.DataDir)
mocked_create_paths.assert_called_with(os.path.join('tests', 'dir'))
assert data_path == os.path.join('tests', 'dir'), 'Result should be "tests/dir"'
mocked_create_paths.assert_called_with(Path('tests', 'dir'))
assert data_path == Path(BASE_DIR, 'tests', 'dir'), 'Result should be "tests/dir"'
@patch('openlp.core.common.applocation.Settings')
@ -71,7 +72,7 @@ def test_get_data_path_with_custom_location(MockSettings):
# THEN: the mocked Settings methods were called and the value returned was our set up value
MockSettings.return_value.contains.assert_called_with('advanced/data path')
MockSettings.return_value.value.assert_called_with('advanced/data path')
assert data_path == Path('custom', 'dir'), 'Result should be "custom/dir"'
assert data_path == Path(BASE_DIR, 'custom', 'dir'), 'Result should be "custom/dir"'
@patch('openlp.core.common.applocation.Path.glob')
@ -140,7 +141,7 @@ def test_get_directory_for_app_dir(mocked_get_frozen_path):
directory = AppLocation.get_directory(AppLocation.AppDir)
# THEN: check that the correct directory is returned
assert directory == Path('app', 'dir'), 'Directory should be "app/dir"'
assert directory == Path(BASE_DIR, 'app', 'dir'), 'Directory should be "app/dir"'
@patch('openlp.core.common.applocation.get_frozen_path')
@ -162,7 +163,7 @@ def test_get_directory_for_plugins_dir(mocked_sys, mocked_split, mocked_abspath,
directory = AppLocation.get_directory(AppLocation.PluginsDir)
# THEN: The correct directory should be returned
assert directory == Path('dir', 'plugins'), 'Directory should be "dir/plugins"'
assert directory == Path(BASE_DIR, 'dir', 'plugins'), 'Directory should be "dir/plugins"'
@patch('openlp.core.common.sys')