Migrate Display

Signed-off-by: Tim <tim.bentley@gmail.com>
This commit is contained in:
Tim Bentley 2020-02-01 21:12:07 +00:00
parent d08762426c
commit 020661059f
18 changed files with 97 additions and 99 deletions

View File

@ -241,6 +241,7 @@ class Settings(QtCore.QSettings):
'core/loop delay': 5, 'core/loop delay': 5,
'core/recent files': [], 'core/recent files': [],
'core/save prompt': False, 'core/save prompt': False,
'core/screens': '{}',
'core/screen blank': False, 'core/screen blank': False,
'core/show splash': True, 'core/show splash': True,
'core/logo background color': '#ffffff', 'core/logo background color': '#ffffff',

View File

@ -35,7 +35,6 @@ from openlp.core.common import ThemeLevel
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.mixins import LogMixin from openlp.core.common.mixins import LogMixin
from openlp.core.common.registry import Registry, RegistryBase from openlp.core.common.registry import Registry, RegistryBase
from openlp.core.common.settings import Settings
from openlp.core.common.utils import wait_for from openlp.core.common.utils import wait_for
from openlp.core.display.screens import ScreenList from openlp.core.display.screens import ScreenList
from openlp.core.display.window import DisplayWindow from openlp.core.display.window import DisplayWindow
@ -535,7 +534,7 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow):
def generate_footer(self): def generate_footer(self):
""" """
""" """
footer_template = Settings().value('songs/footer template') footer_template = self.settings.value('songs/footer template')
# Keep this in sync with the list in songstab.py # Keep this in sync with the list in songstab.py
vars = { vars = {
'title': TITLE, 'title': TITLE,
@ -544,7 +543,7 @@ class ThemePreviewRenderer(LogMixin, DisplayWindow):
'Author who wrote the lyrics of a song'), 'Author who wrote the lyrics of a song'),
'authors_words': [AUTHOR], 'authors_words': [AUTHOR],
'copyright': FOOTER_COPYRIGHT, 'copyright': FOOTER_COPYRIGHT,
'ccli_license': Settings().value('core/ccli number'), 'ccli_license': self.settings.value('core/ccli number'),
'ccli_license_label': translate('SongsPlugin.MediaItem', 'CCLI License'), 'ccli_license_label': translate('SongsPlugin.MediaItem', 'CCLI License'),
'ccli_number': CCLI_NO, 'ccli_number': CCLI_NO,
} }

View File

@ -30,7 +30,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common import Singleton from openlp.core.common import Singleton
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -215,6 +214,7 @@ class ScreenList(metaclass=Singleton):
screen_list.desktop.screenCountChanged.connect(screen_list.on_screen_count_changed) screen_list.desktop.screenCountChanged.connect(screen_list.on_screen_count_changed)
screen_list.desktop.primaryScreenChanged.connect(screen_list.on_primary_screen_changed) screen_list.desktop.primaryScreenChanged.connect(screen_list.on_primary_screen_changed)
screen_list.update_screens() screen_list.update_screens()
cls.settings = Registry().get('settings')
screen_list.load_screen_settings() screen_list.load_screen_settings()
return screen_list return screen_list
@ -222,13 +222,7 @@ class ScreenList(metaclass=Singleton):
""" """
Loads the screen size and the screen number from the settings. Loads the screen size and the screen number from the settings.
""" """
# Add the screen settings to the settings dict. This has to be done here due to cyclic dependency. screen_settings = self.settings.value('core/screens')
# Do not do this anywhere else.
screen_settings = {
'core/screens': '{}'
}
Settings.extend_default_settings(screen_settings)
screen_settings = Settings().value('core/screens')
if screen_settings: if screen_settings:
for number, screen_dict in screen_settings.items(): for number, screen_dict in screen_settings.items():
# Sometimes this loads as a string instead of an int # Sometimes this loads as a string instead of an int
@ -244,7 +238,7 @@ class ScreenList(metaclass=Singleton):
""" """
Saves the screen size and screen settings Saves the screen size and screen settings
""" """
Settings().setValue('core/screens', {screen.number: screen.to_dict() for screen in self.screens}) self.settings.setValue('core/screens', {screen.number: screen.to_dict() for screen in self.screens})
def get_display_screen_list(self): def get_display_screen_list(self):
""" """

View File

@ -24,7 +24,7 @@ Provide HTML Tag management and Formatting Tag access class
import json import json
from openlp.core.common.i18n import translate from openlp.core.common.i18n import translate
from openlp.core.common.settings import Settings from openlp.core.common.registry import Registry
class FormattingTags(object): class FormattingTags(object):
@ -49,7 +49,7 @@ class FormattingTags(object):
The tags to be saved.. The tags to be saved..
""" """
# Formatting Tags were also known as display tags. # Formatting Tags were also known as display tags.
Settings().setValue('formattingTags/html_tags', json.dumps(new_tags) if new_tags else '') Registry().get('settings').setValue('formattingTags/html_tags', json.dumps(new_tags) if new_tags else '')
@staticmethod @staticmethod
def load_tags(): def load_tags():
@ -152,7 +152,7 @@ class FormattingTags(object):
# Append the base tags. # Append the base tags.
FormattingTags.add_html_tags(base_tags) FormattingTags.add_html_tags(base_tags)
FormattingTags.add_html_tags(temporary_tags) FormattingTags.add_html_tags(temporary_tags)
user_expands_string = str(Settings().value('formattingTags/html_tags')) user_expands_string = str(Registry().get('settings').value('formattingTags/html_tags'))
# If we have some user ones added them as well # If we have some user ones added them as well
if user_expands_string: if user_expands_string:
user_tags = json.loads(user_expands_string) user_tags = json.loads(user_expands_string)

View File

@ -31,7 +31,6 @@ import time
from PyQt5 import QtCore from PyQt5 import QtCore
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.display.screens import ScreenList from openlp.core.display.screens import ScreenList
from openlp.core.lib import image_to_byte, resize_image from openlp.core.lib import image_to_byte, resize_image
from openlp.core.threading import ThreadWorker, run_thread from openlp.core.threading import ThreadWorker, run_thread
@ -339,7 +338,7 @@ class ImageManager(QtCore.QObject):
width = self.width if image.width == -1 else image.width width = self.width if image.width == -1 else image.width
height = self.height if image.height == -1 else image.height height = self.height if image.height == -1 else image.height
image.image = resize_image(image.path, width, height, image.background, image.image = resize_image(image.path, width, height, image.background,
Settings().value('advanced/ignore aspect ratio')) Registry().get('settings').value('advanced/ignore aspect ratio'))
# Set the priority to Lowest and stop here as we need to process more important images first. # Set the priority to Lowest and stop here as we need to process more important images first.
if image.priority == Priority.Normal: if image.priority == Priority.Normal:
self._conversion_queue.modify_priority(image, Priority.Lowest) self._conversion_queue.modify_priority(image, Priority.Lowest)

View File

@ -29,7 +29,6 @@ from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import UiStrings, translate from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import ServiceItemContext from openlp.core.lib import ServiceItemContext
from openlp.core.lib.plugin import StringContent from openlp.core.lib.plugin import StringContent
from openlp.core.lib.serviceitem import ServiceItem from openlp.core.lib.serviceitem import ServiceItem
@ -322,7 +321,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties):
""" """
file_paths, selected_filter = FileDialog.getOpenFileNames( file_paths, selected_filter = FileDialog.getOpenFileNames(
self, self.on_new_prompt, self, self.on_new_prompt,
Settings().value(self.settings_section + '/last directory'), self.settings.value(self.settings_section + '/last directory'),
self.on_new_file_masks) self.on_new_file_masks)
log.info('New file(s) {file_paths}'.format(file_paths=file_paths)) log.info('New file(s) {file_paths}'.format(file_paths=file_paths))
if file_paths: if file_paths:
@ -385,8 +384,9 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties):
if target_group is None: if target_group is None:
self.list_view.clear() self.list_view.clear()
self.load_list(full_list, target_group) self.load_list(full_list, target_group)
Settings().setValue(self.settings_section + '/last directory', file_paths[0].parent) self.settings.setValue(self.settings_section + '/last directory', file_paths[0].parent)
Settings().setValue('{section}/{section} files'.format(section=self.settings_section), self.get_file_list()) self.settings.setValue('{section}/{section} files'.
format(section=self.settings_section), self.get_file_list())
if duplicates_found: if duplicates_found:
critical_error_message_box(UiStrings().Duplicate, critical_error_message_box(UiStrings().Duplicate,
translate('OpenLP.MediaManagerItem', translate('OpenLP.MediaManagerItem',
@ -470,10 +470,10 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties):
""" """
Allows the list click action to be determined dynamically Allows the list click action to be determined dynamically
""" """
if Settings().value('advanced/double click live'): if self.settings.value('advanced/double click live'):
if self.can_make_live: if self.can_make_live:
self.on_live_click() self.on_live_click()
elif not Settings().value('advanced/single click preview'): elif not self.settings.value('advanced/single click preview'):
# NOTE: The above check is necessary to prevent bug #1419300 # NOTE: The above check is necessary to prevent bug #1419300
if self.can_preview: if self.can_preview:
self.on_preview_click() self.on_preview_click()
@ -482,7 +482,7 @@ class MediaManagerItem(QtWidgets.QWidget, RegistryProperties):
""" """
Allows the change of current item in the list to be actioned Allows the change of current item in the list to be actioned
""" """
if Settings().value('advanced/single click preview') and self.quick_preview_allowed \ if self.settings.value('advanced/single click preview') and self.quick_preview_allowed \
and self.list_view.selectedIndexes() and self.auto_select_id == -1: and self.list_view.selectedIndexes() and self.auto_select_id == -1:
self.on_preview_click(True) self.on_preview_click(True)

View File

@ -27,7 +27,6 @@ from openlp.core.common.enum import PluginStatus
from openlp.core.common.i18n import UiStrings from openlp.core.common.i18n import UiStrings
from openlp.core.common.mixins import RegistryProperties from openlp.core.common.mixins import RegistryProperties
from openlp.core.common.registry import Registry, RegistryBase from openlp.core.common.registry import Registry, RegistryBase
from openlp.core.common.settings import Settings
from openlp.core.version import get_version from openlp.core.version import get_version
@ -164,14 +163,14 @@ class Plugin(RegistryBase, RegistryProperties):
""" """
Sets the status of the plugin Sets the status of the plugin
""" """
self.status = Settings().value(self.settings_section + '/status') self.status = self.settings.value(self.settings_section + '/status')
def toggle_status(self, new_status): def toggle_status(self, new_status):
""" """
Changes the status of the plugin and remembers it Changes the status of the plugin and remembers it
""" """
self.status = new_status self.status = new_status
Settings().setValue(self.settings_section + '/status', self.status) self.settings.setValue(self.settings_section + '/status', self.status)
if new_status == PluginStatus.Active: if new_status == PluginStatus.Active:
self.initialise() self.initialise()
elif new_status == PluginStatus.Inactive: elif new_status == PluginStatus.Inactive:

View File

@ -90,7 +90,7 @@ class SelectPlanForm(QtWidgets.QDialog, Ui_SelectPlanDialog):
""" """
Close dialog. Close dialog.
:param r: The result of the dialog. :param result_code: The result of the dialog.
""" """
log.debug('Closing PlanningCenterForm') log.debug('Closing PlanningCenterForm')
return QtWidgets.QDialog.done(self, result_code) return QtWidgets.QDialog.done(self, result_code)

View File

@ -58,6 +58,7 @@ class TestController(TestCase):
""" """
Registry.create() Registry.create()
self.registry = Registry() self.registry = Registry()
Registry().register('settings', Settings())
self.mocked_live_controller = MagicMock() self.mocked_live_controller = MagicMock()
self.desktop = MagicMock() self.desktop = MagicMock()
self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.primaryScreen.return_value = SCREEN['primary']
@ -79,7 +80,6 @@ class TestController(TestCase):
Registry().register('renderer', self.mocked_renderer) Registry().register('renderer', self.mocked_renderer)
flask_app.config['TESTING'] = True flask_app.config['TESTING'] = True
self.client = flask_app.test_client() self.client = flask_app.test_client()
Registry().register('settings', Settings())
def test_controller_text_empty(self): def test_controller_text_empty(self):
""" """

View File

@ -51,6 +51,7 @@ class TestScreenList(TestCase):
self.application = QtWidgets.QApplication.instance() self.application = QtWidgets.QApplication.instance()
Registry.create() Registry.create()
Registry().register('settings', MagicMock())
self.application.setOrganizationName('OpenLP-tests') self.application.setOrganizationName('OpenLP-tests')
self.application.setOrganizationDomain('openlp.org') self.application.setOrganizationDomain('openlp.org')
self.screens = ScreenList.create(self.desktop) self.screens = ScreenList.create(self.desktop)

View File

@ -22,7 +22,6 @@
Package to test the openlp.core.lib.formattingtags package. Package to test the openlp.core.lib.formattingtags package.
""" """
import copy import copy
from unittest import TestCase
from unittest.mock import patch from unittest.mock import patch
from openlp.core.lib.formattingtags import FormattingTags from openlp.core.lib.formattingtags import FormattingTags
@ -38,65 +37,57 @@ TAG = {
} }
class TestFormattingTags(TestCase): def test_get_html_tags_no_user_tags(mock_settings):
"""
Test the FormattingTags class' get_html_tags static method.
"""
with patch('openlp.core.lib.translate') as mocked_translate, \
patch('openlp.core.common.settings') as mocked_settings, \
patch('openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
mocked_settings.value.return_value = ''
mocked_json.load.return_value = []
def tearDown(self): # WHEN: Get the display tags.
""" FormattingTags.load_tags()
Clean up the FormattingTags class. old_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
""" FormattingTags.load_tags()
FormattingTags.html_expands = [] new_tags_list = FormattingTags.get_html_tags()
def test_get_html_tags_no_user_tags(self): # THEN: Lists should be identical.
""" assert old_tags_list == new_tags_list, 'The formatting tag lists should be identical.'
Test the FormattingTags class' get_html_tags static method.
"""
with patch('openlp.core.lib.translate') as mocked_translate, \
patch('openlp.core.common.settings') as mocked_settings, \
patch('openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate, comment: string_to_translate
mocked_settings.value.return_value = ''
mocked_json.load.return_value = []
# WHEN: Get the display tags.
FormattingTags.load_tags()
old_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
FormattingTags.load_tags()
new_tags_list = FormattingTags.get_html_tags()
# THEN: Lists should be identical. def test_get_html_tags_with_user_tags(mock_settings):
assert old_tags_list == new_tags_list, 'The formatting tag lists should be identical.' """
FormattingTags class - test the get_html_tags(), add_html_tags() and remove_html_tag() methods.
"""
with patch('openlp.core.lib.translate') as mocked_translate, \
patch('openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
mock_settings.value.return_value = ''
mocked_json.loads.side_effect = [[], [TAG]]
def test_get_html_tags_with_user_tags(self): # WHEN: Get the display tags.
""" FormattingTags.load_tags()
FormattingTags class - test the get_html_tags(), add_html_tags() and remove_html_tag() methods. old_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
"""
with patch('openlp.core.lib.translate') as mocked_translate, \
patch('openlp.core.common.settings') as mocked_settings, \
patch('openlp.core.lib.formattingtags.json') as mocked_json:
# GIVEN: Our mocked modules and functions.
mocked_translate.side_effect = lambda module, string_to_translate: string_to_translate
mocked_settings.value.return_value = ''
mocked_json.loads.side_effect = [[], [TAG]]
# WHEN: Get the display tags. # WHEN: Add our tag and get the tags again.
FormattingTags.load_tags() FormattingTags.load_tags()
old_tags_list = copy.deepcopy(FormattingTags.get_html_tags()) FormattingTags.add_html_tags([TAG])
new_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
# WHEN: Add our tag and get the tags again. # THEN: Lists should not be identical.
FormattingTags.load_tags() assert old_tags_list != new_tags_list, 'The lists should be different.'
FormattingTags.add_html_tags([TAG])
new_tags_list = copy.deepcopy(FormattingTags.get_html_tags())
# THEN: Lists should not be identical. # THEN: Added tag and last tag should be the same.
assert old_tags_list != new_tags_list, 'The lists should be different.' new_tag = new_tags_list.pop()
assert TAG == new_tag, 'Tags should be identical.'
# THEN: Added tag and last tag should be the same. # WHEN: Remove the new tag.
new_tag = new_tags_list.pop() FormattingTags.remove_html_tag(len(new_tags_list))
assert TAG == new_tag, 'Tags should be identical.'
# WHEN: Remove the new tag. # THEN: The lists should now be identical.
FormattingTags.remove_html_tag(len(new_tags_list)) assert old_tags_list == FormattingTags.get_html_tags(), 'The lists should be identical.'
# THEN: The lists should now be identical.
assert old_tags_list == FormattingTags.get_html_tags(), 'The lists should be identical.'

View File

@ -24,6 +24,7 @@ Package to test the openlp.core.lib.mediamanageritem package.
from unittest import TestCase from unittest import TestCase
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from openlp.core.common.registry import Registry
from openlp.core.lib.mediamanageritem import MediaManagerItem from openlp.core.lib.mediamanageritem import MediaManagerItem
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -36,20 +37,20 @@ class TestMediaManagerItem(TestCase, TestMixin):
""" """
Mock out stuff for all the tests Mock out stuff for all the tests
""" """
Registry.create()
self.setup_patcher = patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup') self.setup_patcher = patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup')
self.mocked_setup = self.setup_patcher.start() self.mocked_setup = self.setup_patcher.start()
self.addCleanup(self.setup_patcher.stop) self.addCleanup(self.setup_patcher.stop)
@patch('openlp.core.lib.mediamanageritem.Settings')
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click') @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
def test_on_double_clicked(self, mocked_on_preview_click, MockedSettings): def test_on_double_clicked(self, mocked_on_preview_click):
""" """
Test that when an item is double-clicked then the item is previewed Test that when an item is double-clicked then the item is previewed
""" """
# GIVEN: A setting to enable "Double-click to go live" and a media manager item # GIVEN: A setting to enable "Double-click to go live" and a media manager item
mocked_settings = MagicMock() mocked_settings = MagicMock()
mocked_settings.value.return_value = False mocked_settings.value.return_value = False
MockedSettings.return_value = mocked_settings Registry().register('settings', mocked_settings)
mmi = MediaManagerItem(None) mmi = MediaManagerItem(None)
mmi.can_preview = True mmi.can_preview = True
mmi.can_make_live = True mmi.can_make_live = True
@ -79,16 +80,15 @@ class TestMediaManagerItem(TestCase, TestMixin):
assert mmi.can_make_live is True, 'There should be a make live by default' assert mmi.can_make_live is True, 'There should be a make live by default'
assert mmi.can_add_to_service is True, 'There should be a add to service icon by default' assert mmi.can_add_to_service is True, 'There should be a add to service icon by default'
@patch('openlp.core.lib.mediamanageritem.Settings')
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click') @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
def test_on_double_clicked_go_live(self, mocked_on_live_click, MockedSettings): def test_on_double_clicked_go_live(self, mocked_on_live_click):
""" """
Test that when "Double-click to go live" is enabled that the item goes live Test that when "Double-click to go live" is enabled that the item goes live
""" """
# GIVEN: A setting to enable "Double-click to go live" and a media manager item # GIVEN: A setting to enable "Double-click to go live" and a media manager item
mocked_settings = MagicMock() mocked_settings = MagicMock()
mocked_settings.value.side_effect = lambda x: x == 'advanced/double click live' mocked_settings.value.side_effect = lambda x: x == 'advanced/double click live'
MockedSettings.return_value = mocked_settings Registry().register('settings', mocked_settings)
mmi = MediaManagerItem(None) mmi = MediaManagerItem(None)
mmi.can_preview = True mmi.can_preview = True
mmi.can_make_live = True mmi.can_make_live = True
@ -100,18 +100,16 @@ class TestMediaManagerItem(TestCase, TestMixin):
# THEN: on_live_click() should have been called # THEN: on_live_click() should have been called
mocked_on_live_click.assert_called_with() mocked_on_live_click.assert_called_with()
@patch('openlp.core.lib.mediamanageritem.Settings')
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click') @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click')
@patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click') @patch('openlp.core.lib.mediamanageritem.MediaManagerItem.on_preview_click')
def test_on_double_clicked_single_click_preview(self, mocked_on_preview_click, mocked_on_live_click, def test_on_double_clicked_single_click_preview(self, mocked_on_preview_click, mocked_on_live_click):
MockedSettings):
""" """
Test that when "Single-click preview" is enabled then nothing happens on double-click Test that when "Single-click preview" is enabled then nothing happens on double-click
""" """
# GIVEN: A setting to enable "Double-click to go live" and a media manager item # GIVEN: A setting to enable "Double-click to go live" and a media manager item
mocked_settings = MagicMock() mocked_settings = MagicMock()
mocked_settings.value.side_effect = lambda x: x == 'advanced/single click preview' mocked_settings.value.side_effect = lambda x: x == 'advanced/single click preview'
MockedSettings.return_value = mocked_settings Registry().register('settings', mocked_settings)
mmi = MediaManagerItem(None) mmi = MediaManagerItem(None)
mmi.can_preview = True mmi.can_preview = True
mmi.can_make_live = True mmi.can_make_live = True

View File

@ -25,6 +25,7 @@ from unittest import TestCase
from unittest.mock import patch from unittest.mock import patch
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.plugins.media.mediaplugin import MediaPlugin from openlp.plugins.media.mediaplugin import MediaPlugin
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -35,6 +36,7 @@ class TestMediaPlugin(TestCase, TestMixin):
""" """
def setUp(self): def setUp(self):
Registry.create() Registry.create()
Registry().register('settings', Settings())
@patch('openlp.plugins.media.mediaplugin.Plugin.initialise') @patch('openlp.plugins.media.mediaplugin.Plugin.initialise')
def test_initialise(self, mocked_initialise): def test_initialise(self, mocked_initialise):

View File

@ -88,9 +88,9 @@ class TestPdfController(TestCase, TestMixin):
self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.primaryScreen.return_value = SCREEN['primary']
self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenCount.return_value = SCREEN['number']
self.desktop.screenGeometry.return_value = SCREEN['size'] self.desktop.screenGeometry.return_value = SCREEN['size']
self.screens = ScreenList.create(self.desktop)
Settings().extend_default_settings(__default_settings__) Settings().extend_default_settings(__default_settings__)
Registry().register('settings', Settings()) Registry().register('settings', Settings())
self.screens = ScreenList.create(self.desktop)
self.temp_folder_path = Path(mkdtemp()) self.temp_folder_path = Path(mkdtemp())
self.thumbnail_folder_path = Path(mkdtemp()) self.thumbnail_folder_path = Path(mkdtemp())
self.mock_plugin = MagicMock() self.mock_plugin = MagicMock()

View File

@ -28,6 +28,7 @@ from unittest import TestCase
from unittest.mock import MagicMock, patch from unittest.mock import MagicMock, patch
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
@ -41,6 +42,7 @@ class TestOpenLyricsExport(TestCase, TestMixin):
Create the registry Create the registry
""" """
Registry.create() Registry.create()
Registry().register('settings', Settings())
self.temp_folder = Path(mkdtemp()) self.temp_folder = Path(mkdtemp())
def tearDown(self): def tearDown(self):

View File

@ -92,6 +92,7 @@ class TestOpenLyricsImport(TestCase, TestMixin):
self.setup_application() self.setup_application()
Registry.create() Registry.create()
self.build_settings() self.build_settings()
Registry().register('settings', Settings())
def tearDown(self): def tearDown(self):
""" """

View File

@ -56,8 +56,9 @@ class TestSettingsForm(TestCase, TestMixin):
self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.primaryScreen.return_value = SCREEN['primary']
self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenCount.return_value = SCREEN['number']
self.desktop.screenGeometry.return_value = SCREEN['size'] self.desktop.screenGeometry.return_value = SCREEN['size']
self.screens = ScreenList.create(self.desktop)
Registry.create() Registry.create()
Registry().register('settings', MagicMock())
self.screens = ScreenList.create(self.desktop)
self.form = settingsform.SettingsForm() self.form = settingsform.SettingsForm()
def tearDown(self): def tearDown(self):

View File

@ -235,7 +235,6 @@ class TestSelectPlanForm(TestCase, TestMixin):
# GIVEN: An SelectPlanForm instance with airplane mode enabled, resources available, # GIVEN: An SelectPlanForm instance with airplane mode enabled, resources available,
# mocked out "on_new_service_clicked" # mocked out "on_new_service_clicked"
with patch('PyQt5.QtWidgets.QDialog.exec'), \ with patch('PyQt5.QtWidgets.QDialog.exec'), \
patch('openlp.core.common.registry.Registry.get'), \
patch('openlp.plugins.planningcenter.lib.songimport.PlanningCenterSongImport.finish') \ patch('openlp.plugins.planningcenter.lib.songimport.PlanningCenterSongImport.finish') \
as mock_song_import, \ as mock_song_import, \
patch('openlp.plugins.planningcenter.lib.customimport.CustomSlide') as mock_custom_slide_import, \ patch('openlp.plugins.planningcenter.lib.customimport.CustomSlide') as mock_custom_slide_import, \
@ -245,6 +244,11 @@ class TestSelectPlanForm(TestCase, TestMixin):
mock_date.today.return_value = date(2019, 9, 29) mock_date.today.return_value = date(2019, 9, 29)
mock_date.side_effect = lambda *args, **kw: date(*args, **kw) mock_date.side_effect = lambda *args, **kw: date(*args, **kw)
self.form.exec() self.form.exec()
Registry().register('service_manager', MagicMock())
Registry().register('plugin_manager', MagicMock())
Registry().register('songs', MagicMock())
Registry().register('bibles', MagicMock())
Registry().register('custom', MagicMock())
# WHEN: The Service Type combo is set to index 1 and the Select Plan combo box is set to # WHEN: The Service Type combo is set to index 1 and the Select Plan combo box is set to
# index 1 and the "Import New" button is clicked # index 1 and the "Import New" button is clicked
self.form.service_type_combo_box.setCurrentIndex(1) self.form.service_type_combo_box.setCurrentIndex(1)
@ -262,7 +266,6 @@ class TestSelectPlanForm(TestCase, TestMixin):
# GIVEN: An SelectPlanForm instance with airplane mode enabled, resources available, # GIVEN: An SelectPlanForm instance with airplane mode enabled, resources available,
# mocked out "on_new_service_clicked" # mocked out "on_new_service_clicked"
with patch('PyQt5.QtWidgets.QDialog.exec'), \ with patch('PyQt5.QtWidgets.QDialog.exec'), \
patch('openlp.core.common.registry.Registry.get'), \
patch('openlp.plugins.planningcenter.lib.songimport.PlanningCenterSongImport.finish') \ patch('openlp.plugins.planningcenter.lib.songimport.PlanningCenterSongImport.finish') \
as mock_song_import, \ as mock_song_import, \
patch('openlp.plugins.planningcenter.lib.customimport.CustomSlide') as mock_custom_slide_import, \ patch('openlp.plugins.planningcenter.lib.customimport.CustomSlide') as mock_custom_slide_import, \
@ -272,6 +275,11 @@ class TestSelectPlanForm(TestCase, TestMixin):
mock_date.today.return_value = date(2019, 9, 29) mock_date.today.return_value = date(2019, 9, 29)
mock_date.side_effect = lambda *args, **kw: date(*args, **kw) mock_date.side_effect = lambda *args, **kw: date(*args, **kw)
self.form.exec() self.form.exec()
Registry().register('service_manager', MagicMock())
Registry().register('plugin_manager', MagicMock())
Registry().register('songs', MagicMock())
Registry().register('bibles', MagicMock())
Registry().register('custom', MagicMock())
# WHEN: The Service Type combo is set to index 1 and the Select Plan combo box is # WHEN: The Service Type combo is set to index 1 and the Select Plan combo box is
# set to index 1 and the "Update" button is clicked # set to index 1 and the "Update" button is clicked
self.form.service_type_combo_box.setCurrentIndex(1) self.form.service_type_combo_box.setCurrentIndex(1)
@ -289,7 +297,6 @@ class TestSelectPlanForm(TestCase, TestMixin):
# GIVEN: An SelectPlanForm instance with airplane mode enabled, resources available, # GIVEN: An SelectPlanForm instance with airplane mode enabled, resources available,
# mocked out "on_new_service_clicked" # mocked out "on_new_service_clicked"
with patch('PyQt5.QtWidgets.QDialog.exec'), \ with patch('PyQt5.QtWidgets.QDialog.exec'), \
patch('openlp.core.common.registry.Registry.get') as mock_get, \
patch('openlp.plugins.planningcenter.lib.songimport.PlanningCenterSongImport.finish'), \ patch('openlp.plugins.planningcenter.lib.songimport.PlanningCenterSongImport.finish'), \
patch('openlp.plugins.planningcenter.lib.customimport.CustomSlide'), \ patch('openlp.plugins.planningcenter.lib.customimport.CustomSlide'), \
patch('openlp.plugins.planningcenter.forms.selectplanform.parse_reference') as mock_bible_import, \ patch('openlp.plugins.planningcenter.forms.selectplanform.parse_reference') as mock_bible_import, \
@ -299,8 +306,11 @@ class TestSelectPlanForm(TestCase, TestMixin):
mock_date.side_effect = lambda *args, **kw: date(*args, **kw) mock_date.side_effect = lambda *args, **kw: date(*args, **kw)
mock_bibles = {} mock_bibles = {}
mock_bibles['other_bible'] = MagicMock() mock_bibles['other_bible'] = MagicMock()
mock_get.return_value.plugin.manager.get_bibles.return_value = mock_bibles Registry().register('service_manager', MagicMock())
mock_get.return_value.version_combo_box.currentText.return_value = '' Registry().register('plugin_manager', MagicMock())
Registry().register('songs', MagicMock())
Registry().register('bibles', MagicMock())
Registry().register('custom', MagicMock())
self.form.exec() self.form.exec()
# WHEN: The Service Type combo is set to index 1 and the Select Plan combo box # WHEN: The Service Type combo is set to index 1 and the Select Plan combo box
# is set to index 1 and the "Import New" button is clicked # is set to index 1 and the "Import New" button is clicked