Merge branch 'more_fixes' into 'master'

More Bug fixes

See merge request openlp/openlp!164
This commit is contained in:
Raoul Snyman 2020-04-09 21:55:27 +00:00
commit 3547430096
17 changed files with 42 additions and 57 deletions

View File

@ -49,7 +49,6 @@ class HttpWorker(ThreadWorker):
""" """
address = Registry().get('settings_thread').value('api/ip address') address = Registry().get('settings_thread').value('api/ip address')
port = Registry().get('settings_thread').value('api/port') port = Registry().get('settings_thread').value('api/port')
Registry().execute('get_website_version')
try: try:
application.static_folder = str(AppLocation.get_section_data_path('remotes') / 'static') application.static_folder = str(AppLocation.get_section_data_path('remotes') / 'static')
self.server = create_server(application, host=address, port=port) self.server = create_server(application, host=address, port=port)

View File

@ -18,7 +18,6 @@
# You should have received a copy of the GNU General Public License # # You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. # # along with this program. If not, see <https://www.gnu.org/licenses/>. #
########################################################################## ##########################################################################
import json import json
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry

View File

@ -64,7 +64,7 @@ def service_set():
id = int(data.get('id', -1)) id = int(data.get('id', -1))
except ValueError: except ValueError:
abort(400) abort(400)
Registry().get('service_manager').set_item(id) Registry().get('service_manager').servicemanager_set_item.emit(id)
return '', 204 return '', 204

View File

@ -1179,6 +1179,8 @@ var Display = {
footerStyle.color = Display._theme.font_footer_color; footerStyle.color = Display._theme.font_footer_color;
footerStyle["font-family"] = Display._theme.font_footer_name; footerStyle["font-family"] = Display._theme.font_footer_name;
footerStyle["font-size"] = "" + Display._theme.font_footer_size + "pt"; footerStyle["font-size"] = "" + Display._theme.font_footer_size + "pt";
footerStyle["font-style"] = !!Display._theme.font_footer_italics ? "italic" : "";
footerStyle["font-weight"] = !!Display._theme.font_footer_bold ? "bold" : "";
footerStyle["white-space"] = Display._theme.font_footer_wrap ? "normal" : "nowrap"; footerStyle["white-space"] = Display._theme.font_footer_wrap ? "normal" : "nowrap";
Display._footerContainer.style.cssText = ""; Display._footerContainer.style.cssText = "";
for (var footerKey in footerStyle) { for (var footerKey in footerStyle) {

View File

@ -509,7 +509,7 @@ def get_start_tags(raw_text):
return raw_text + ''.join(end_tags), ''.join(start_tags), ''.join(html_tags) return raw_text + ''.join(end_tags), ''.join(start_tags), ''.join(html_tags)
class ThemePreviewRenderer(LogMixin, DisplayWindow): class ThemePreviewRenderer(DisplayWindow, LogMixin):
""" """
A virtual display used for rendering thumbnails and other offscreen tasks A virtual display used for rendering thumbnails and other offscreen tasks
""" """

View File

@ -31,7 +31,7 @@ from PyQt5 import QtCore, QtWebChannel, QtWidgets
from openlp.core.common.applocation import AppLocation from openlp.core.common.applocation import AppLocation
from openlp.core.common.enum import ServiceItemType from openlp.core.common.enum import ServiceItemType
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import LogMixin, RegistryProperties
from openlp.core.common.path import path_to_str from openlp.core.common.path import path_to_str
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.utils import wait_for from openlp.core.common.utils import wait_for
@ -118,7 +118,7 @@ class DisplayWatcher(QtCore.QObject):
self.initialised.emit(is_initialised) self.initialised.emit(is_initialised)
class DisplayWindow(QtWidgets.QWidget, RegistryProperties): class DisplayWindow(QtWidgets.QWidget, RegistryProperties, LogMixin):
""" """
This is a window to show the output This is a window to show the output
""" """

View File

@ -1273,7 +1273,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
:param current_index: The combo box index for the selected item :param current_index: The combo box index for the selected item
""" """
self.service_theme = self.theme_combo_box.currentText() self.service_theme = self.theme_combo_box.currentText()
self.settings.setValue(self.main_window.service_manager_settings_section + '/service theme', self.service_theme) self.settings.setValue('servicemanager/service theme', self.service_theme)
self.regenerate_service_items(True) self.regenerate_service_items(True)
def theme_change(self): def theme_change(self):
@ -1289,7 +1289,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
""" """
Set the theme for the current service remotely Set the theme for the current service remotely
""" """
self.service_theme = self.settings.value(self.main_window.service_manager_settings_section + '/service theme') self.service_theme = self.settings.value('servicemanager/service theme')
find_and_set_in_combo_box(self.theme_combo_box, self.service_theme) find_and_set_in_combo_box(self.theme_combo_box, self.service_theme)
self.regenerate_service_items(True) self.regenerate_service_items(True)
@ -1622,7 +1622,7 @@ class ServiceManager(QtWidgets.QWidget, RegistryBase, Ui_ServiceManager, LogMixi
find_and_set_in_combo_box(self.theme_combo_box, self.service_theme) find_and_set_in_combo_box(self.theme_combo_box, self.service_theme)
self.regenerate_service_items() self.regenerate_service_items()
def on_theme_change_action(self): def on_theme_change_action(self, field=None):
""" """
Handles theme change events Handles theme change events
""" """

View File

@ -296,6 +296,9 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
""" """
self.footer_area_page.font_name = self.theme.font_footer_name self.footer_area_page.font_name = self.theme.font_footer_name
self.footer_area_page.font_color = self.theme.font_footer_color self.footer_area_page.font_color = self.theme.font_footer_color
self.footer_area_page.is_bold = self.theme.font_footer_bold
self.footer_area_page.is_italic = self.theme.font_footer_italics
self.footer_area_page.font_size = self.theme.font_footer_size
def set_position_page_values(self): def set_position_page_values(self):
""" """
@ -363,6 +366,7 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
self.theme.background_filename = self.background_page.stream_mrl self.theme.background_filename = self.background_page.stream_mrl
# main page # main page
self.theme.font_main_name = self.main_area_page.font_name self.theme.font_main_name = self.main_area_page.font_name
self.theme.font_main_color = self.main_area_page.font_color
self.theme.font_main_size = self.main_area_page.font_size self.theme.font_main_size = self.main_area_page.font_size
self.theme.font_main_line_adjustment = self.main_area_page.line_spacing self.theme.font_main_line_adjustment = self.main_area_page.line_spacing
self.theme.font_main_outline_size = self.main_area_page.outline_size self.theme.font_main_outline_size = self.main_area_page.outline_size
@ -371,7 +375,10 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
self.theme.font_main_italics = self.main_area_page.is_italic self.theme.font_main_italics = self.main_area_page.is_italic
# footer page # footer page
self.theme.font_footer_name = self.footer_area_page.font_name self.theme.font_footer_name = self.footer_area_page.font_name
self.theme.font_footer_color = self.footer_area_page.font_color
self.theme.font_footer_size = self.footer_area_page.font_size self.theme.font_footer_size = self.footer_area_page.font_size
self.theme.font_footer_bold = self.footer_area_page.is_bold
self.theme.font_footer_italics = self.footer_area_page.is_italic
# position page (main) # position page (main)
self.theme.font_main_override = not self.area_position_page.use_main_default_location self.theme.font_main_override = not self.area_position_page.use_main_default_location
if self.theme.font_main_override: if self.theme.font_main_override:

View File

@ -141,7 +141,6 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
Constructor Constructor
""" """
super(ThemeManager, self).__init__(parent) super(ThemeManager, self).__init__(parent)
self.settings_section = 'themes'
# Variables # Variables
self._theme_list = {} self._theme_list = {}
self.old_background_image_path = None self.old_background_image_path = None
@ -165,7 +164,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
process the bootstrap initialise setup request process the bootstrap initialise setup request
""" """
self.setup_ui(self) self.setup_ui(self)
self.global_theme = self.settings.value(self.settings_section + '/global theme') self.global_theme = self.settings.value('themes/global theme')
self.build_theme_path() self.build_theme_path()
def bootstrap_post_set_up(self): def bootstrap_post_set_up(self):
@ -206,7 +205,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
:rtype: None :rtype: None
""" """
self.theme_path = AppLocation.get_section_data_path(self.settings_section) self.theme_path = AppLocation.get_section_data_path('themes')
self.thumb_path = self.theme_path / 'thumbnails' self.thumb_path = self.theme_path / 'thumbnails'
create_paths(self.theme_path, self.thumb_path) create_paths(self.theme_path, self.thumb_path)
@ -249,7 +248,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
""" """
Change the global theme when it is changed through the Themes settings tab Change the global theme when it is changed through the Themes settings tab
""" """
self.global_theme = self.settings.value(self.settings_section + '/global theme') self.global_theme = self.settings.value('themes/global theme')
self.log_debug('change_global_from_tab {text}'.format(text=self.global_theme)) self.log_debug('change_global_from_tab {text}'.format(text=self.global_theme))
for count in range(0, self.theme_list_widget.count()): for count in range(0, self.theme_list_widget.count()):
# reset the old name # reset the old name
@ -282,7 +281,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
self.global_theme = self.theme_list_widget.item(count).text() self.global_theme = self.theme_list_widget.item(count).text()
name = translate('OpenLP.ThemeManager', '{text} (default)').format(text=self.global_theme) name = translate('OpenLP.ThemeManager', '{text} (default)').format(text=self.global_theme)
self.theme_list_widget.item(count).setText(name) self.theme_list_widget.item(count).setText(name)
self.settings.setValue(self.settings_section + '/global theme', self.global_theme) self.settings.setValue('themes/global theme', self.global_theme)
Registry().execute('theme_update_global') Registry().execute('theme_update_global')
self._push_themes() self._push_themes()
@ -423,12 +422,12 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
FileDialog.getSaveFileName(self.main_window, FileDialog.getSaveFileName(self.main_window,
translate('OpenLP.ThemeManager', translate('OpenLP.ThemeManager',
'Save Theme - ({name})').format(name=theme_name), 'Save Theme - ({name})').format(name=theme_name),
self.settings.value(self.settings_section + '/last directory export'), self.settings.value('themes/last directory export'),
translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'), translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'),
translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)')) translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
self.application.set_busy_cursor() self.application.set_busy_cursor()
if export_path: if export_path:
self.settings.setValue(self.settings_section + '/last directory export', export_path.parent) self.settings.setValue('themes/last directory export', export_path.parent)
if self._export_theme(export_path.with_suffix('.otz'), theme_name): if self._export_theme(export_path.with_suffix('.otz'), theme_name):
QtWidgets.QMessageBox.information(self, QtWidgets.QMessageBox.information(self,
translate('OpenLP.ThemeManager', 'Theme Exported'), translate('OpenLP.ThemeManager', 'Theme Exported'),
@ -472,7 +471,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
file_paths, filter_used = FileDialog.getOpenFileNames( file_paths, filter_used = FileDialog.getOpenFileNames(
self, self,
translate('OpenLP.ThemeManager', 'Select Theme Import File'), translate('OpenLP.ThemeManager', 'Select Theme Import File'),
self.settings.value(self.settings_section + '/last directory import'), self.settings.value('themes/last directory import'),
translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)')) translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
self.log_info('New Themes {file_paths}'.format(file_paths=file_paths)) self.log_info('New Themes {file_paths}'.format(file_paths=file_paths))
if not file_paths: if not file_paths:
@ -481,7 +480,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
new_themes = [] new_themes = []
for file_path in file_paths: for file_path in file_paths:
new_themes.append(self.unzip_theme(file_path, self.theme_path)) new_themes.append(self.unzip_theme(file_path, self.theme_path))
self.settings.setValue(self.settings_section + '/last directory import', file_path.parent) self.settings.setValue('themes/last directory import', file_path.parent)
self.update_preview_images(new_themes) self.update_preview_images(new_themes)
self.load_themes() self.load_themes()
self.application.set_normal_cursor() self.application.set_normal_cursor()
@ -491,7 +490,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
Imports any themes on start up and makes sure there is at least one theme Imports any themes on start up and makes sure there is at least one theme
""" """
self.application.set_busy_cursor() self.application.set_busy_cursor()
theme_paths = AppLocation.get_files(self.settings_section, '.otz') theme_paths = AppLocation.get_files('themes', '.otz')
new_themes = [] new_themes = []
for theme_path in theme_paths: for theme_path in theme_paths:
theme_path = self.theme_path / theme_path theme_path = self.theme_path / theme_path
@ -502,7 +501,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
theme = Theme() theme = Theme()
theme.theme_name = UiStrings().Default theme.theme_name = UiStrings().Default
self.save_theme(theme) self.save_theme(theme)
self.settings.setValue(self.settings_section + '/global theme', theme.theme_name) self.settings.setValue('themes/global theme', theme.theme_name)
new_themes = [theme.theme_name] new_themes = [theme.theme_name]
if new_themes: if new_themes:
self.update_preview_images(new_themes) self.update_preview_images(new_themes)
@ -516,7 +515,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
""" """
self._theme_list.clear() self._theme_list.clear()
self.theme_list_widget.clear() self.theme_list_widget.clear()
files = AppLocation.get_files(self.settings_section, '/*.json') files = AppLocation.get_files('themes', '/*.json')
# Sort the themes by its name considering language specific # Sort the themes by its name considering language specific
files.sort(key=lambda file_name: get_locale_key(str(file_name))) files.sort(key=lambda file_name: get_locale_key(str(file_name)))
# now process the file list of png files # now process the file list of png files
@ -788,7 +787,7 @@ class ThemeManager(QtWidgets.QWidget, RegistryBase, Ui_ThemeManager, LogMixin, R
:param confirm: Do we display a confirm box before run checks. :param confirm: Do we display a confirm box before run checks.
:return: True or False depending on the validity. :return: True or False depending on the validity.
""" """
self.global_theme = self.settings.value(self.settings_section + '/global theme') self.global_theme = self.settings.value('themes/global theme')
if check_item_selected(self.theme_list_widget, select_text): if check_item_selected(self.theme_list_widget, select_text):
item = self.theme_list_widget.currentItem() item = self.theme_list_widget.currentItem()
theme = item.text() theme = item.text()

View File

@ -202,7 +202,7 @@ class ThemesTab(SettingsTab):
['Bible Theme', 'Song Theme'] ['Bible Theme', 'Song Theme']
""" """
# Reload as may have been triggered by the ThemeManager. # Reload as may have been triggered by the ThemeManager.
self.global_theme = self.settings.value(self.settings_section + '/global theme') self.global_theme = self.settings.value('themes/global theme')
self.default_combo_box.clear() self.default_combo_box.clear()
self.default_combo_box.addItems(theme_list) self.default_combo_box.addItems(theme_list)
find_and_set_in_combo_box(self.default_combo_box, self.global_theme) find_and_set_in_combo_box(self.default_combo_box, self.global_theme)

View File

@ -113,7 +113,7 @@ def state_media(state):
@pytest.yield_fixture() @pytest.yield_fixture()
def tmp_folder(): def temp_folder():
t_folder = mkdtemp(prefix='openlp_') t_folder = mkdtemp(prefix='openlp_')
yield t_folder yield t_folder
shutil.rmtree(t_folder, ignore_errors=True) shutil.rmtree(t_folder, ignore_errors=True)

View File

@ -50,7 +50,7 @@ def test_service_set_calls_service_manager(flask_client, settings):
Registry().register('service_manager', fake_service_manager) Registry().register('service_manager', fake_service_manager)
res = flask_client.post('/api/v2/service/show', json=dict(id=400)) res = flask_client.post('/api/v2/service/show', json=dict(id=400))
assert res.status_code == 204 assert res.status_code == 204
fake_service_manager.set_item.assert_called_once_with(400) fake_service_manager.servicemanager_set_item.emit.assert_called_once_with(400)
def test_service_direction_requires_login(flask_client, settings): def test_service_direction_requires_login(flask_client, settings):

View File

@ -146,12 +146,12 @@ def test_delete_database_with_db_file_name():
assert result is False, 'The result of delete_file should be False (was rigged that way)' assert result is False, 'The result of delete_file should be False (was rigged that way)'
def test_skip_db_upgrade_with_no_database(tmp_folder): def test_skip_db_upgrade_with_no_database(temp_folder):
""" """
Test the upgrade_db function does not try to update a missing database Test the upgrade_db function does not try to update a missing database
""" """
# GIVEN: Database URL that does not (yet) exist # GIVEN: Database URL that does not (yet) exist
url = 'sqlite:///{tmp}/test_db.sqlite'.format(tmp=tmp_folder) url = 'sqlite:///{tmp}/test_db.sqlite'.format(tmp=temp_folder)
mocked_upgrade = MagicMock() mocked_upgrade = MagicMock()
# WHEN: We attempt to upgrade a non-existent database # WHEN: We attempt to upgrade a non-existent database

View File

@ -23,7 +23,6 @@ Package to test the openlp.core.ui.thememanager package.
""" """
import os import os
import shutil import shutil
import pytest
from pathlib import Path from pathlib import Path
from tempfile import mkdtemp from tempfile import mkdtemp
from unittest.mock import ANY, Mock, MagicMock, patch, call from unittest.mock import ANY, Mock, MagicMock, patch, call
@ -35,13 +34,6 @@ from openlp.core.ui.thememanager import ThemeManager
from tests.utils.constants import RESOURCE_PATH from tests.utils.constants import RESOURCE_PATH
@pytest.yield_fixture()
def temp_folder():
tmp_folder = mkdtemp()
yield tmp_folder
shutil.rmtree(tmp_folder)
@patch('openlp.core.ui.thememanager.zipfile.ZipFile.__init__') @patch('openlp.core.ui.thememanager.zipfile.ZipFile.__init__')
@patch('openlp.core.ui.thememanager.zipfile.ZipFile.write') @patch('openlp.core.ui.thememanager.zipfile.ZipFile.write')
def test_export_theme(mocked_zipfile_write, mocked_zipfile_init, registry): def test_export_theme(mocked_zipfile_write, mocked_zipfile_init, registry):

View File

@ -22,9 +22,7 @@
For the Presentation tests For the Presentation tests
""" """
import pytest import pytest
import shutil
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from tempfile import mkdtemp
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem
@ -43,9 +41,7 @@ def media_item(settings):
@pytest.yield_fixture() @pytest.yield_fixture()
def mock_plugin(): def mock_plugin(temp_folder):
m_plugin = MagicMock() m_plugin = MagicMock()
temp_folder = mkdtemp()
m_plugin.settings_section = temp_folder m_plugin.settings_section = temp_folder
yield m_plugin yield m_plugin
shutil.rmtree(temp_folder)

View File

@ -21,10 +21,8 @@
""" """
This module contains tests for the db submodule of the Songs plugin. This module contains tests for the db submodule of the Songs plugin.
""" """
import pytest
import os import os
import shutil import shutil
from tempfile import mkdtemp
from openlp.core.lib.db import upgrade_db from openlp.core.lib.db import upgrade_db
from openlp.plugins.songs.lib import upgrade from openlp.plugins.songs.lib import upgrade
@ -32,13 +30,6 @@ from openlp.plugins.songs.lib.db import Author, AuthorType, Book, Song
from tests.utils.constants import TEST_RESOURCES_PATH from tests.utils.constants import TEST_RESOURCES_PATH
@pytest.yield_fixture()
def tmp_folder():
t_folder = mkdtemp()
yield t_folder
shutil.rmtree(t_folder, ignore_errors=True)
def test_add_author(): def test_add_author():
""" """
Test adding an author to a song Test adding an author to a song
@ -194,13 +185,13 @@ def test_add_songbooks():
assert len(song.songbook_entries) == 2, 'There should be two Songbook entries.' assert len(song.songbook_entries) == 2, 'There should be two Songbook entries.'
def test_upgrade_old_song_db(settings, tmp_folder): def test_upgrade_old_song_db(settings, temp_folder):
""" """
Test that we can upgrade an old song db to the current schema Test that we can upgrade an old song db to the current schema
""" """
# GIVEN: An old song db # GIVEN: An old song db
old_db_path = os.path.join(TEST_RESOURCES_PATH, "songs", 'songs-1.9.7.sqlite') old_db_path = os.path.join(TEST_RESOURCES_PATH, "songs", 'songs-1.9.7.sqlite')
old_db_tmp_path = os.path.join(tmp_folder, 'songs-1.9.7.sqlite') old_db_tmp_path = os.path.join(temp_folder, 'songs-1.9.7.sqlite')
shutil.copyfile(old_db_path, old_db_tmp_path) shutil.copyfile(old_db_path, old_db_tmp_path)
db_url = 'sqlite:///' + old_db_tmp_path db_url = 'sqlite:///' + old_db_tmp_path
@ -211,13 +202,13 @@ def test_upgrade_old_song_db(settings, tmp_folder):
assert updated_to_version == latest_version, 'The song DB should have been upgrade to the latest version' assert updated_to_version == latest_version, 'The song DB should have been upgrade to the latest version'
def test_upgrade_invalid_song_db(settings, tmp_folder): def test_upgrade_invalid_song_db(settings, temp_folder):
""" """
Test that we can upgrade an invalid song db to the current schema Test that we can upgrade an invalid song db to the current schema
""" """
# GIVEN: A song db with invalid version # GIVEN: A song db with invalid version
invalid_db_path = os.path.join(TEST_RESOURCES_PATH, "songs", 'songs-2.2-invalid.sqlite') invalid_db_path = os.path.join(TEST_RESOURCES_PATH, "songs", 'songs-2.2-invalid.sqlite')
invalid_db_tmp_path = os.path.join(tmp_folder, 'songs-2.2-invalid.sqlite') invalid_db_tmp_path = os.path.join(temp_folder, 'songs-2.2-invalid.sqlite')
shutil.copyfile(invalid_db_path, invalid_db_tmp_path) shutil.copyfile(invalid_db_path, invalid_db_tmp_path)
db_url = 'sqlite:///' + invalid_db_tmp_path db_url = 'sqlite:///' + invalid_db_tmp_path

View File

@ -85,13 +85,13 @@ def add_records(projector_db, test):
return added return added
def test_upgrade_old_projector_db(tmp_folder): def test_upgrade_old_projector_db(temp_folder):
""" """
Test that we can upgrade a version 1 db to the current schema Test that we can upgrade a version 1 db to the current schema
""" """
# GIVEN: An old prjector db # GIVEN: An old prjector db
old_db = os.path.join(TEST_RESOURCES_PATH, "projector", TEST_DB_PJLINK1) old_db = os.path.join(TEST_RESOURCES_PATH, "projector", TEST_DB_PJLINK1)
tmp_db = os.path.join(tmp_folder, TEST_DB) tmp_db = os.path.join(temp_folder, TEST_DB)
shutil.copyfile(old_db, tmp_db) shutil.copyfile(old_db, tmp_db)
db_url = 'sqlite:///{db}'.format(db=tmp_db) db_url = 'sqlite:///{db}'.format(db=tmp_db)
@ -103,11 +103,11 @@ def test_upgrade_old_projector_db(tmp_folder):
@pytest.yield_fixture() @pytest.yield_fixture()
def projector(tmp_folder, settings): def projector(temp_folder, settings):
""" """
Set up anything necessary for all tests Set up anything necessary for all tests
""" """
tmpdb_url = 'sqlite:///{db}'.format(db=os.path.join(tmp_folder, TEST_DB)) tmpdb_url = 'sqlite:///{db}'.format(db=os.path.join(temp_folder, TEST_DB))
with patch('openlp.core.projectors.db.init_url') as mocked_init_url: with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
mocked_init_url.return_value = tmpdb_url mocked_init_url.return_value = tmpdb_url
proj = ProjectorDB() proj = ProjectorDB()