diff --git a/openlp/core/app.py b/openlp/core/app.py index 204f33bcb..2498f5c42 100644 --- a/openlp/core/app.py +++ b/openlp/core/app.py @@ -311,6 +311,18 @@ def set_up_logging(log_path): print(f'Logging to: {file_path} and level {log.level}') +def set_up_web_engine_cache(web_cache_path): + """ + Setup path for the qt web engine to dump it's files + + :param Path web_cache_path: The folder for the web engine files + :rtype: None + """ + web_engine_profile = QtWebEngineWidgets.QWebEngineProfile.defaultProfile() + web_engine_profile.setCachePath(str(web_cache_path)) + web_engine_profile.setPersistentStoragePath(str(web_cache_path)) + + def backup_if_version_changed(settings): """ Check version of settings and the application version and backup if the version is different. @@ -421,6 +433,7 @@ def main(): portable_path = resolve(portable_path) data_path = portable_path / 'Data' set_up_logging(portable_path / 'Other') + set_up_web_engine_cache(portable_path / 'Other' / 'web_cache') log.info('Running portable') portable_settings_path = data_path / 'OpenLP.ini' # Make this our settings file @@ -436,6 +449,7 @@ def main(): else: application.setApplicationName('OpenLP') set_up_logging(AppLocation.get_directory(AppLocation.CacheDir)) + set_up_web_engine_cache(portable_path / 'Other' / 'web_cache') # Set the libvlc environment variable if we're frozen if getattr(sys, 'frozen', False) and is_win(): # Path to libvlc and the plugins diff --git a/tests/openlp_core/test_app.py b/tests/openlp_core/test_app.py index 636e0b7ac..d1b0c2812 100644 --- a/tests/openlp_core/test_app.py +++ b/tests/openlp_core/test_app.py @@ -306,7 +306,9 @@ def test_backup_on_upgrade(mocked_question, mocked_get_version, qapp, settings): @patch('openlp.core.app.OpenLP') @patch('openlp.core.app.sys') @patch('openlp.core.app.backup_if_version_changed') -def test_main(mock_backup, mock_sys, mock_openlp, app_main_env): +@patch('openlp.core.app.set_up_web_engine_cache') +@patch('openlp.core.app.set_up_logging') +def test_main(mock_logging, mock_web_cache, mock_backup, mock_sys, mock_openlp, app_main_env): """ Test the main method performs primary actions """ @@ -319,8 +321,10 @@ def test_main(mock_backup, mock_sys, mock_openlp, app_main_env): # WHEN: the main method is run app_main() - # THEN: Check the application is run and exited + # THEN: Check the application is run and exited with logging and web cache path set openlp_instance.run.assert_called_once() + mock_logging.assert_called_once() + mock_web_cache.assert_called_once() mock_sys.exit.assert_called_once()