forked from openlp/openlp
Merge branch 'settings_core_2' into 'master'
Settings core 2 See merge request openlp/openlp!127
This commit is contained in:
commit
d08762426c
@ -24,7 +24,7 @@ from functools import wraps
|
|||||||
|
|
||||||
from webob import Response
|
from webob import Response
|
||||||
|
|
||||||
from openlp.core.common.settings import Settings
|
from openlp.core.common.registry import Registry
|
||||||
|
|
||||||
|
|
||||||
def check_auth(auth):
|
def check_auth(auth):
|
||||||
@ -34,8 +34,8 @@ def check_auth(auth):
|
|||||||
:param auth: the authorisation object which needs to be tested
|
:param auth: the authorisation object which needs to be tested
|
||||||
:return Whether authentication have been successful
|
:return Whether authentication have been successful
|
||||||
"""
|
"""
|
||||||
auth_code = "{user}:{password}".format(user=Settings().value('api/user id'),
|
auth_code = "{user}:{password}".format(user=Registry().get('settings').value('api/user id'),
|
||||||
password=Settings().value('api/password'))
|
password=Registry().get('settings').value('api/password'))
|
||||||
try:
|
try:
|
||||||
auth_base = base64.b64encode(auth_code)
|
auth_base = base64.b64encode(auth_code)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
@ -64,7 +64,7 @@ def requires_auth(f):
|
|||||||
"""
|
"""
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
if not Settings().value('api/authentication enabled'):
|
if not Registry().get('settings').value('api/authentication enabled'):
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
req = args[0]
|
req = args[0]
|
||||||
if not hasattr(req, 'authorization'):
|
if not hasattr(req, 'authorization'):
|
||||||
|
@ -36,7 +36,6 @@ from openlp.core.common.i18n import UiStrings, translate
|
|||||||
from openlp.core.common.mixins import LogMixin, RegistryProperties
|
from openlp.core.common.mixins import LogMixin, RegistryProperties
|
||||||
from openlp.core.common.path import create_paths
|
from openlp.core.common.path import create_paths
|
||||||
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.threading import ThreadWorker, run_thread
|
from openlp.core.threading import ThreadWorker, run_thread
|
||||||
|
|
||||||
from openlp.core.api import app as application
|
from openlp.core.api import app as application
|
||||||
@ -52,8 +51,8 @@ class HttpWorker(ThreadWorker):
|
|||||||
"""
|
"""
|
||||||
Run the thread.
|
Run the thread.
|
||||||
"""
|
"""
|
||||||
address = Settings().value('api/ip address')
|
address = Registry().get('settings').value('api/ip address')
|
||||||
port = Settings().value('api/port')
|
port = Registry().get('settings').value('api/port')
|
||||||
Registry().execute('get_website_version')
|
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')
|
||||||
@ -113,7 +112,7 @@ class HttpServer(RegistryBase, RegistryProperties, LogMixin):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
progress.close()
|
progress.close()
|
||||||
self.application.process_events()
|
self.application.process_events()
|
||||||
Settings().setValue('remotes/download version', self.version)
|
self.settings.setValue('remotes/download version', self.version)
|
||||||
|
|
||||||
def website_version(self):
|
def website_version(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1,14 +1,33 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
import json
|
import json
|
||||||
from flask import jsonify, Response, request
|
from flask import jsonify, Response, request
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from openlp.core.common.settings import Settings
|
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
|
|
||||||
|
|
||||||
def login_required(f):
|
def login_required(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
if not Settings().value('api/authentication enabled'):
|
if not Registry().get('settings').value('api/authentication enabled'):
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
token = request.headers.get('Authorization', '')
|
token = request.headers.get('Authorization', '')
|
||||||
if token == Registry().get('authentication_token'):
|
if token == Registry().get('authentication_token'):
|
||||||
@ -33,14 +52,14 @@ def extract_request(json_string, name):
|
|||||||
|
|
||||||
# ----------------------- OLD AUTH SECTION ---------------------
|
# ----------------------- OLD AUTH SECTION ---------------------
|
||||||
def check_auth(username, password):
|
def check_auth(username, password):
|
||||||
return Settings().value('api/user id') == username and \
|
return Registry().get('settings').value('api/user id') == username and \
|
||||||
Settings().value('api/password') == password
|
Registry().get('settings').value('api/password') == password
|
||||||
|
|
||||||
|
|
||||||
def old_auth(f):
|
def old_auth(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
if not Settings().value('api/authentication enabled'):
|
if not Registry().get('settings').value('api/authentication enabled'):
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
auth = request.authorization
|
auth = request.authorization
|
||||||
if not auth or not check_auth(auth.username, auth.password):
|
if not auth or not check_auth(auth.username, auth.password):
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
from flask import Blueprint, send_from_directory
|
from flask import Blueprint, send_from_directory
|
||||||
from openlp.core.common.applocation import AppLocation
|
from openlp.core.common.applocation import AppLocation
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import json
|
|||||||
|
|
||||||
from openlp.core.common.httputils import get_web_page
|
from openlp.core.common.httputils import get_web_page
|
||||||
from openlp.core.common.mixins import RegistryProperties
|
from openlp.core.common.mixins import RegistryProperties
|
||||||
from openlp.core.common.settings import Settings
|
|
||||||
|
|
||||||
|
|
||||||
class Poller(RegistryProperties):
|
class Poller(RegistryProperties):
|
||||||
@ -44,14 +43,14 @@ class Poller(RegistryProperties):
|
|||||||
'service': self.service_manager.service_id,
|
'service': self.service_manager.service_id,
|
||||||
'slide': self.live_controller.selected_row or 0,
|
'slide': self.live_controller.selected_row or 0,
|
||||||
'item': self.live_controller.service_item.unique_identifier if self.live_controller.service_item else '',
|
'item': self.live_controller.service_item.unique_identifier if self.live_controller.service_item else '',
|
||||||
'twelve': Settings().value('api/twelve hour'),
|
'twelve': self.settings.value('api/twelve hour'),
|
||||||
'blank': self.live_controller.blank_screen.isChecked(),
|
'blank': self.live_controller.blank_screen.isChecked(),
|
||||||
'theme': self.live_controller.theme_screen.isChecked(),
|
'theme': self.live_controller.theme_screen.isChecked(),
|
||||||
'display': self.live_controller.desktop_screen.isChecked(),
|
'display': self.live_controller.desktop_screen.isChecked(),
|
||||||
'version': 3,
|
'version': 3,
|
||||||
'isSecure': Settings().value('api/authentication enabled'),
|
'isSecure': self.settings.value('api/authentication enabled'),
|
||||||
'isAuthorised': False,
|
'isAuthorised': False,
|
||||||
'chordNotation': Settings().value('songs/chord notation'),
|
'chordNotation': self.settings.value('songs/chord notation'),
|
||||||
'isStageActive': self.is_stage_active(),
|
'isStageActive': self.is_stage_active(),
|
||||||
'isLiveActive': self.is_live_active(),
|
'isLiveActive': self.is_live_active(),
|
||||||
'isChordsActive': self.is_chords_active()
|
'isChordsActive': self.is_chords_active()
|
||||||
|
@ -26,7 +26,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
|||||||
from openlp.core.common import get_network_interfaces
|
from openlp.core.common import get_network_interfaces
|
||||||
from openlp.core.common.i18n import UiStrings, translate
|
from openlp.core.common.i18n import UiStrings, translate
|
||||||
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.settingstab import SettingsTab
|
from openlp.core.lib.settingstab import SettingsTab
|
||||||
from openlp.core.ui.icons import UiIcons
|
from openlp.core.ui.icons import UiIcons
|
||||||
|
|
||||||
@ -211,16 +210,16 @@ class ApiTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
Load the configuration and update the server configuration if necessary
|
Load the configuration and update the server configuration if necessary
|
||||||
"""
|
"""
|
||||||
self.port_spin_box.setText(str(Settings().value(self.settings_section + '/port')))
|
self.port_spin_box.setText(str(self.settings.value(self.settings_section + '/port')))
|
||||||
self.address_edit.setText(Settings().value(self.settings_section + '/ip address'))
|
self.address_edit.setText(self.settings.value(self.settings_section + '/ip address'))
|
||||||
self.twelve_hour = Settings().value(self.settings_section + '/twelve hour')
|
self.twelve_hour = self.settings.value(self.settings_section + '/twelve hour')
|
||||||
self.twelve_hour_check_box.setChecked(self.twelve_hour)
|
self.twelve_hour_check_box.setChecked(self.twelve_hour)
|
||||||
self.thumbnails = Settings().value(self.settings_section + '/thumbnails')
|
self.thumbnails = self.settings.value(self.settings_section + '/thumbnails')
|
||||||
self.thumbnails_check_box.setChecked(self.thumbnails)
|
self.thumbnails_check_box.setChecked(self.thumbnails)
|
||||||
self.user_login_group_box.setChecked(Settings().value(self.settings_section + '/authentication enabled'))
|
self.user_login_group_box.setChecked(self.settings.value(self.settings_section + '/authentication enabled'))
|
||||||
self.user_id.setText(Settings().value(self.settings_section + '/user id'))
|
self.user_id.setText(self.settings.value(self.settings_section + '/user id'))
|
||||||
self.password.setText(Settings().value(self.settings_section + '/password'))
|
self.password.setText(self.settings.value(self.settings_section + '/password'))
|
||||||
self.current_version_value.setText(Settings().value('remotes/download version'))
|
self.current_version_value.setText(self.settings.value('remotes/download version'))
|
||||||
self.master_version_value.setText(Registry().get_flag('website_version'))
|
self.master_version_value.setText(Registry().get_flag('website_version'))
|
||||||
if self.master_version_value.text() == self.current_version_value.text():
|
if self.master_version_value.text() == self.current_version_value.text():
|
||||||
self.update_site_group_box.setEnabled(False)
|
self.update_site_group_box.setEnabled(False)
|
||||||
@ -230,14 +229,14 @@ class ApiTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
Save the configuration and update the server configuration if necessary
|
Save the configuration and update the server configuration if necessary
|
||||||
"""
|
"""
|
||||||
if Settings().value(self.settings_section + '/ip address') != self.address_edit.text():
|
if self.settings.value(self.settings_section + '/ip address') != self.address_edit.text():
|
||||||
self.settings_form.register_post_process('remotes_config_updated')
|
self.settings_form.register_post_process('remotes_config_updated')
|
||||||
Settings().setValue(self.settings_section + '/ip address', self.address_edit.text())
|
self.settings.setValue(self.settings_section + '/ip address', self.address_edit.text())
|
||||||
Settings().setValue(self.settings_section + '/twelve hour', self.twelve_hour)
|
self.settings.setValue(self.settings_section + '/twelve hour', self.twelve_hour)
|
||||||
Settings().setValue(self.settings_section + '/thumbnails', self.thumbnails)
|
self.settings.setValue(self.settings_section + '/thumbnails', self.thumbnails)
|
||||||
Settings().setValue(self.settings_section + '/authentication enabled', self.user_login_group_box.isChecked())
|
self.settings.setValue(self.settings_section + '/authentication enabled', self.user_login_group_box.isChecked())
|
||||||
Settings().setValue(self.settings_section + '/user id', self.user_id.text())
|
self.settings.setValue(self.settings_section + '/user id', self.user_id.text())
|
||||||
Settings().setValue(self.settings_section + '/password', self.password.text())
|
self.settings.setValue(self.settings_section + '/password', self.password.text())
|
||||||
if self.update_site_group_box.isChecked():
|
if self.update_site_group_box.isChecked():
|
||||||
self.settings_form.register_post_process('download_website')
|
self.settings_form.register_post_process('download_website')
|
||||||
|
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
@ -1,3 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
from openlp.core.api.versions.v1.controller import controller_views
|
from openlp.core.api.versions.v1.controller import controller_views
|
||||||
from openlp.core.api.versions.v1.core import core_views
|
from openlp.core.api.versions.v1.core import core_views
|
||||||
from openlp.core.api.versions.v1.service import service_views
|
from openlp.core.api.versions.v1.service import service_views
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import urllib.request
|
import urllib.request
|
||||||
@ -6,7 +26,6 @@ from pathlib import Path
|
|||||||
from openlp.core.api.lib import old_auth, old_success_response, extract_request
|
from openlp.core.api.lib import old_auth, old_success_response, extract_request
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.common.applocation import AppLocation
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.common.settings import Settings
|
|
||||||
from openlp.core.lib import create_thumb
|
from openlp.core.lib import create_thumb
|
||||||
from openlp.core.lib.serviceitem import ItemCapabilities
|
from openlp.core.lib.serviceitem import ItemCapabilities
|
||||||
|
|
||||||
@ -35,7 +54,8 @@ def controller_text_api():
|
|||||||
item['chords_text'] = str(frame.get('chords_text', ''))
|
item['chords_text'] = str(frame.get('chords_text', ''))
|
||||||
item['text'] = frame['text']
|
item['text'] = frame['text']
|
||||||
item['html'] = current_item.get_rendered_frame(index)
|
item['html'] = current_item.get_rendered_frame(index)
|
||||||
elif current_item.is_image() and not frame.get('image', '') and Settings().value('api/thumbnails'):
|
elif current_item.is_image() and not frame.get('image', '') and \
|
||||||
|
Registry().get('settings').value('api/thumbnails'):
|
||||||
thumbnail_path = os.path.join('images', 'thumbnails', frame['title'])
|
thumbnail_path = os.path.join('images', 'thumbnails', frame['title'])
|
||||||
full_thumbnail_path = AppLocation.get_data_path() / thumbnail_path
|
full_thumbnail_path = AppLocation.get_data_path() / thumbnail_path
|
||||||
if not full_thumbnail_path.exists():
|
if not full_thumbnail_path.exists():
|
||||||
@ -50,7 +70,8 @@ def controller_text_api():
|
|||||||
item['title'] = str(frame['display_title'])
|
item['title'] = str(frame['display_title'])
|
||||||
if current_item.is_capable(ItemCapabilities.HasNotes):
|
if current_item.is_capable(ItemCapabilities.HasNotes):
|
||||||
item['slide_notes'] = str(frame['notes'])
|
item['slide_notes'] = str(frame['notes'])
|
||||||
if current_item.is_capable(ItemCapabilities.HasThumbnails) and Settings().value('api/thumbnails'):
|
if current_item.is_capable(ItemCapabilities.HasThumbnails) and \
|
||||||
|
Registry().get('settings').value('api/thumbnails'):
|
||||||
# If the file is under our app directory tree send the portion after the match
|
# If the file is under our app directory tree send the portion after the match
|
||||||
data_path = str(AppLocation.get_data_path())
|
data_path = str(AppLocation.get_data_path())
|
||||||
if frame['image'][0:len(data_path)] == data_path:
|
if frame['image'][0:len(data_path)] == data_path:
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
from openlp.core.api.lib import old_auth, old_success_response
|
from openlp.core.api.lib import old_auth, old_success_response
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.lib import image_to_byte
|
from openlp.core.lib import image_to_byte
|
||||||
@ -6,7 +26,6 @@ from openlp.core.state import State
|
|||||||
|
|
||||||
from flask import jsonify, Blueprint
|
from flask import jsonify, Blueprint
|
||||||
|
|
||||||
|
|
||||||
core_views = Blueprint('old_core', __name__)
|
core_views = Blueprint('old_core', __name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
from openlp.core.api.lib import old_auth, old_success_response, extract_request
|
from openlp.core.api.lib import old_auth, old_success_response, extract_request
|
||||||
from flask import jsonify, request, Blueprint
|
from flask import jsonify, request, Blueprint
|
||||||
|
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
from openlp.core.api.versions.v2.controller import controller_views
|
from openlp.core.api.versions.v2.controller import controller_views
|
||||||
from openlp.core.api.versions.v2.core import core
|
from openlp.core.api.versions.v2.core import core
|
||||||
from openlp.core.api.versions.v2.service import service_views
|
from openlp.core.api.versions.v2.service import service_views
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
import os
|
import os
|
||||||
import urllib.request
|
import urllib.request
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -5,7 +25,6 @@ from pathlib import Path
|
|||||||
from openlp.core.api.lib import login_required
|
from openlp.core.api.lib import login_required
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.common.applocation import AppLocation
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.common.settings import Settings
|
|
||||||
from openlp.core.lib import create_thumb
|
from openlp.core.lib import create_thumb
|
||||||
from openlp.core.lib.serviceitem import ItemCapabilities
|
from openlp.core.lib.serviceitem import ItemCapabilities
|
||||||
|
|
||||||
@ -31,7 +50,8 @@ def controller_text_api():
|
|||||||
item['chords_text'] = str(frame.get('chords_text', ''))
|
item['chords_text'] = str(frame.get('chords_text', ''))
|
||||||
item['text'] = frame['text']
|
item['text'] = frame['text']
|
||||||
item['html'] = current_item.get_rendered_frame(index)
|
item['html'] = current_item.get_rendered_frame(index)
|
||||||
elif current_item.is_image() and not frame.get('image', '') and Settings().value('api/thumbnails'):
|
elif current_item.is_image() and not frame.get('image', '') and \
|
||||||
|
Registry().get('settings').value('api/thumbnails'):
|
||||||
thumbnail_path = os.path.join('images', 'thumbnails', frame['title'])
|
thumbnail_path = os.path.join('images', 'thumbnails', frame['title'])
|
||||||
full_thumbnail_path = AppLocation.get_data_path() / thumbnail_path
|
full_thumbnail_path = AppLocation.get_data_path() / thumbnail_path
|
||||||
if not full_thumbnail_path.exists():
|
if not full_thumbnail_path.exists():
|
||||||
@ -46,7 +66,8 @@ def controller_text_api():
|
|||||||
item['title'] = str(frame['display_title'])
|
item['title'] = str(frame['display_title'])
|
||||||
if current_item.is_capable(ItemCapabilities.HasNotes):
|
if current_item.is_capable(ItemCapabilities.HasNotes):
|
||||||
item['slide_notes'] = str(frame['notes'])
|
item['slide_notes'] = str(frame['notes'])
|
||||||
if current_item.is_capable(ItemCapabilities.HasThumbnails) and Settings().value('api/thumbnails'):
|
if current_item.is_capable(ItemCapabilities.HasThumbnails) and \
|
||||||
|
Registry().get('settings').value('api/thumbnails'):
|
||||||
# If the file is under our app directory tree send the portion after the match
|
# If the file is under our app directory tree send the portion after the match
|
||||||
data_path = str(AppLocation.get_data_path())
|
data_path = str(AppLocation.get_data_path())
|
||||||
if frame['image'][0:len(data_path)] == data_path:
|
if frame['image'][0:len(data_path)] == data_path:
|
||||||
|
@ -1,13 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
from openlp.core.api.lib import login_required
|
from openlp.core.api.lib import login_required
|
||||||
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 image_to_byte
|
from openlp.core.lib import image_to_byte
|
||||||
from openlp.core.lib.plugin import PluginStatus, StringContent
|
from openlp.core.lib.plugin import PluginStatus, StringContent
|
||||||
from openlp.core.state import State
|
from openlp.core.state import State
|
||||||
|
|
||||||
from flask import jsonify, request, abort, Blueprint
|
from flask import jsonify, request, abort, Blueprint
|
||||||
|
|
||||||
|
|
||||||
core = Blueprint('core', __name__)
|
core = Blueprint('core', __name__)
|
||||||
|
|
||||||
|
|
||||||
@ -43,8 +61,8 @@ def plugin_list():
|
|||||||
@core.route('/system')
|
@core.route('/system')
|
||||||
def system_information():
|
def system_information():
|
||||||
data = {}
|
data = {}
|
||||||
data['websocket_port'] = Settings().value('api/websocket port')
|
data['websocket_port'] = Registry().get('settings').value('api/websocket port')
|
||||||
data['login_required'] = Settings().value('api/authentication enabled')
|
data['login_required'] = Registry().get('settings').value('api/authentication enabled')
|
||||||
return jsonify(data)
|
return jsonify(data)
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +73,8 @@ def login():
|
|||||||
abort(400)
|
abort(400)
|
||||||
username = data.get('username', '')
|
username = data.get('username', '')
|
||||||
password = data.get('password', '')
|
password = data.get('password', '')
|
||||||
if username == Settings().value('api/user id') and password == Settings().value('api/password'):
|
if username == Registry().get('settings').value('api/user id') and \
|
||||||
|
password == Registry().get('settings').value('api/password'):
|
||||||
return jsonify({'token': Registry().get('authentication_token')})
|
return jsonify({'token': Registry().get('authentication_token')})
|
||||||
else:
|
else:
|
||||||
return '', 401
|
return '', 401
|
||||||
|
@ -1,3 +1,24 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
from openlp.core.api.lib import login_required
|
from openlp.core.api.lib import login_required
|
||||||
|
|
||||||
from flask import jsonify, request, abort, Blueprint
|
from flask import jsonify, request, abort, Blueprint
|
||||||
|
@ -31,7 +31,6 @@ from websockets import serve
|
|||||||
|
|
||||||
from openlp.core.common.mixins import LogMixin, RegistryProperties
|
from openlp.core.common.mixins import LogMixin, 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.threading import ThreadWorker, run_thread
|
from openlp.core.threading import ThreadWorker, run_thread
|
||||||
|
|
||||||
|
|
||||||
@ -76,8 +75,8 @@ class WebSocketWorker(ThreadWorker, RegistryProperties, LogMixin):
|
|||||||
"""
|
"""
|
||||||
Run the worker.
|
Run the worker.
|
||||||
"""
|
"""
|
||||||
address = Settings().value('api/ip address')
|
address = Registry().get('settings').value('api/ip address')
|
||||||
port = Settings().value('api/websocket port')
|
port = Registry().get('settings').value('api/websocket port')
|
||||||
# Start the event loop
|
# Start the event loop
|
||||||
self.event_loop = asyncio.new_event_loop()
|
self.event_loop = asyncio.new_event_loop()
|
||||||
asyncio.set_event_loop(self.event_loop)
|
asyncio.set_event_loop(self.event_loop)
|
||||||
|
@ -29,7 +29,6 @@ from zeroconf import ServiceInfo, Zeroconf
|
|||||||
|
|
||||||
from openlp.core.common import get_network_interfaces
|
from openlp.core.common import get_network_interfaces
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.common.settings import Settings
|
|
||||||
from openlp.core.threading import ThreadWorker, run_thread
|
from openlp.core.threading import ThreadWorker, run_thread
|
||||||
|
|
||||||
|
|
||||||
@ -91,8 +90,8 @@ def start_zeroconf():
|
|||||||
# When we're running tests, just skip this set up if this flag is set
|
# When we're running tests, just skip this set up if this flag is set
|
||||||
if Registry().get_flag('no_web_server'):
|
if Registry().get_flag('no_web_server'):
|
||||||
return
|
return
|
||||||
http_port = Settings().value('api/port')
|
http_port = Registry().get('settings').value('api/port')
|
||||||
ws_port = Settings().value('api/websocket port')
|
ws_port = Registry().get('settings').value('api/websocket port')
|
||||||
for name, interface in get_network_interfaces().items():
|
for name, interface in get_network_interfaces().items():
|
||||||
worker = ZeroconfWorker(interface['ip'], http_port, ws_port)
|
worker = ZeroconfWorker(interface['ip'], http_port, ws_port)
|
||||||
run_thread(worker, 'api_zeroconf_{name}'.format(name=name))
|
run_thread(worker, 'api_zeroconf_{name}'.format(name=name))
|
||||||
|
@ -31,7 +31,7 @@ import appdirs
|
|||||||
import openlp
|
import openlp
|
||||||
from openlp.core.common import get_frozen_path, is_macosx, is_win
|
from openlp.core.common import get_frozen_path, is_macosx, is_win
|
||||||
from openlp.core.common.path import create_paths
|
from openlp.core.common.path import create_paths
|
||||||
from openlp.core.common.settings import Settings
|
from openlp.core.common.registry import Registry
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -79,8 +79,8 @@ class AppLocation(object):
|
|||||||
:rtype: Path
|
:rtype: Path
|
||||||
"""
|
"""
|
||||||
# Check if we have a different data location.
|
# Check if we have a different data location.
|
||||||
if Settings().contains('advanced/data path'):
|
if Registry().get('settings').contains('advanced/data path'):
|
||||||
path = Path(Settings().value('advanced/data path'))
|
path = Path(Registry().get('settings').value('advanced/data path'))
|
||||||
else:
|
else:
|
||||||
path = AppLocation.get_directory(AppLocation.DataDir)
|
path = AppLocation.get_directory(AppLocation.DataDir)
|
||||||
create_paths(path)
|
create_paths(path)
|
||||||
|
@ -34,7 +34,7 @@ from PyQt5 import QtCore
|
|||||||
|
|
||||||
from openlp.core.common import trace_error_handler
|
from openlp.core.common import trace_error_handler
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.common.settings import ProxyMode, Settings
|
from openlp.core.common.settings import ProxyMode
|
||||||
from openlp.core.threading import ThreadWorker
|
from openlp.core.threading import ThreadWorker
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ def get_proxy_settings(mode=None):
|
|||||||
:return: A dict using the format expected by the requests library.
|
:return: A dict using the format expected by the requests library.
|
||||||
:rtype: dict | None
|
:rtype: dict | None
|
||||||
"""
|
"""
|
||||||
settings = Settings()
|
settings = Registry().get('settings')
|
||||||
if mode is None:
|
if mode is None:
|
||||||
mode = settings.value('advanced/proxy mode')
|
mode = settings.value('advanced/proxy mode')
|
||||||
if mode == ProxyMode.NO_PROXY:
|
if mode == ProxyMode.NO_PROXY:
|
||||||
|
@ -30,7 +30,7 @@ from PyQt5 import QtCore, QtWidgets
|
|||||||
|
|
||||||
from openlp.core.common import Singleton, is_macosx, is_win
|
from openlp.core.common import Singleton, is_macosx, is_win
|
||||||
from openlp.core.common.applocation import AppLocation
|
from openlp.core.common.applocation import AppLocation
|
||||||
from openlp.core.common.settings import Settings
|
from openlp.core.common.registry import Registry
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ class LanguageManager(object):
|
|||||||
"""
|
"""
|
||||||
Retrieve a saved language to use from settings
|
Retrieve a saved language to use from settings
|
||||||
"""
|
"""
|
||||||
language = Settings().value('core/language')
|
language = Registry().get('settings').value('core/language')
|
||||||
language = str(language)
|
language = str(language)
|
||||||
log.info("Language file: '{language}' Loaded from conf file".format(language=language))
|
log.info("Language file: '{language}' Loaded from conf file".format(language=language))
|
||||||
m = re.match(r'\[(.*)\]', language)
|
m = re.match(r'\[(.*)\]', language)
|
||||||
@ -293,7 +293,7 @@ class LanguageManager(object):
|
|||||||
language = str(qm_list[action_name])
|
language = str(qm_list[action_name])
|
||||||
if LanguageManager.auto_language:
|
if LanguageManager.auto_language:
|
||||||
language = '[{language}]'.format(language=language)
|
language = '[{language}]'.format(language=language)
|
||||||
Settings().setValue('core/language', language)
|
Registry().get('settings').setValue('core/language', language)
|
||||||
log.info("Language file: '{language}' written to conf file".format(language=language))
|
log.info("Language file: '{language}' written to conf file".format(language=language))
|
||||||
if message:
|
if message:
|
||||||
QtWidgets.QMessageBox.information(None,
|
QtWidgets.QMessageBox.information(None,
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
|
# ---------------------------------------------------------------------- #
|
||||||
|
# This program is free software: you can redistribute it and/or modify #
|
||||||
|
# it under the terms of the GNU General Public License as published by #
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or #
|
||||||
|
# (at your option) any later version. #
|
||||||
|
# #
|
||||||
|
# This program is distributed in the hope that it will be useful, #
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||||
|
# GNU General Public License for more details. #
|
||||||
|
# #
|
||||||
|
# You should have received a copy of the GNU General Public License #
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
##########################################################################
|
||||||
from flask import Blueprint, request, abort
|
from flask import Blueprint, request, abort
|
||||||
|
|
||||||
from openlp.core.api import app
|
from openlp.core.api import app
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
# Copyright (c) 2008-2020 OpenLP Developers #
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# This program is free software; you can redistribute it and/or modify it #
|
# This program is free software; you can redistribute it and/or modify it #
|
||||||
# under the terms of the GNU General Public License as published by the Free #
|
# under the terms of the GNU General Public License as published by the Free #
|
||||||
|
@ -30,6 +30,7 @@ from openlp.core.state import State
|
|||||||
# Mock QtWebEngineWidgets
|
# Mock QtWebEngineWidgets
|
||||||
# sys.modules['PyQt5.QtWebEngineWidgets'] = MagicMock()
|
# sys.modules['PyQt5.QtWebEngineWidgets'] = MagicMock()
|
||||||
|
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.display.screens import ScreenList
|
from openlp.core.display.screens import ScreenList
|
||||||
from openlp.core.lib.serviceitem import ServiceItem
|
from openlp.core.lib.serviceitem import ServiceItem
|
||||||
@ -78,7 +79,7 @@ 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', MagicMock(**{'value.return_value': 'english'}))
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def test_controller_text_empty(self):
|
def test_controller_text_empty(self):
|
||||||
"""
|
"""
|
||||||
|
@ -43,6 +43,7 @@ class TestInit(TestCase, TestMixin):
|
|||||||
Registry().register('service_list', MagicMock())
|
Registry().register('service_list', MagicMock())
|
||||||
self.build_settings()
|
self.build_settings()
|
||||||
self.password = 'c3VwZXJmbHk6bGFtYXM='
|
self.password = 'c3VwZXJmbHk6bGFtYXM='
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.destroy_settings()
|
self.destroy_settings()
|
||||||
|
@ -60,6 +60,7 @@ class TestApiTab(TestCase, TestMixin):
|
|||||||
self.parent = QtWidgets.QMainWindow()
|
self.parent = QtWidgets.QMainWindow()
|
||||||
Registry().create()
|
Registry().create()
|
||||||
Registry().set_flag('website_version', '00-00-0000')
|
Registry().set_flag('website_version', '00-00-0000')
|
||||||
|
Registry().register('settings', Settings())
|
||||||
self.form = ApiTab(self.parent)
|
self.form = ApiTab(self.parent)
|
||||||
self.interfaces = get_network_interfaces()
|
self.interfaces = get_network_interfaces()
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ class TestWSServer(TestCase, TestMixin):
|
|||||||
self.build_settings()
|
self.build_settings()
|
||||||
Settings().extend_default_settings(__default_settings__)
|
Settings().extend_default_settings(__default_settings__)
|
||||||
Registry().create()
|
Registry().create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
self.poll = Poller()
|
self.poll = Poller()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
|
@ -24,15 +24,15 @@ def test_controller_set_does_not_accept_get(flask_client):
|
|||||||
assert res.status_code == 405
|
assert res.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
def test_controller_set_calls_live_controller(flask_client):
|
def test_controller_set_calls_live_controller(flask_client, settings):
|
||||||
fake_live_controller = MagicMock()
|
fake_live_controller = MagicMock()
|
||||||
Registry.create().register('live_controller', fake_live_controller)
|
Registry().register('live_controller', fake_live_controller)
|
||||||
res = flask_client.post('/api/v2/controller/show', json=dict(id=400))
|
res = flask_client.post('/api/v2/controller/show', json=dict(id=400))
|
||||||
assert res.status_code == 204
|
assert res.status_code == 204
|
||||||
fake_live_controller.slidecontroller_live_set.emit.assert_called_once_with([400])
|
fake_live_controller.slidecontroller_live_set.emit.assert_called_once_with([400])
|
||||||
|
|
||||||
|
|
||||||
def test_controller_direction_requires_login(flask_client):
|
def test_controller_direction_requires_login(flask_client, settings):
|
||||||
Settings().setValue('api/authentication enabled', True)
|
Settings().setValue('api/authentication enabled', True)
|
||||||
res = flask_client.post('/api/v2/controller/progress', json=dict())
|
res = flask_client.post('/api/v2/controller/progress', json=dict())
|
||||||
Settings().setValue('api/authentication enabled', False)
|
Settings().setValue('api/authentication enabled', False)
|
||||||
@ -44,14 +44,14 @@ def test_controller_direction_does_not_accept_get(flask_client):
|
|||||||
assert res.status_code == 405
|
assert res.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
def test_controller_direction_does_fails_on_wrong_data(flask_client):
|
def test_controller_direction_does_fails_on_wrong_data(flask_client, settings):
|
||||||
res = flask_client.post('/api/v2/controller/progress', json=dict(action='foo'))
|
res = flask_client.post('/api/v2/controller/progress', json=dict(action='foo'))
|
||||||
assert res.status_code == 400
|
assert res.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_controller_direction_calls_service_manager(flask_client):
|
def test_controller_direction_calls_service_manager(flask_client, settings):
|
||||||
fake_live_controller = MagicMock()
|
fake_live_controller = MagicMock()
|
||||||
Registry.create().register('live_controller', fake_live_controller)
|
Registry().register('live_controller', fake_live_controller)
|
||||||
res = flask_client.post('/api/v2/controller/progress', json=dict(action='next'))
|
res = flask_client.post('/api/v2/controller/progress', json=dict(action='next'))
|
||||||
assert res.status_code == 204
|
assert res.status_code == 204
|
||||||
fake_live_controller.slidecontroller_live_next.emit.assert_called_once()
|
fake_live_controller.slidecontroller_live_next.emit.assert_called_once()
|
||||||
|
@ -27,7 +27,7 @@ def test_plugins_returns_list(flask_client):
|
|||||||
assert res[0]['name'] == plugin.text_strings[StringContent.Name]['plural']
|
assert res[0]['name'] == plugin.text_strings[StringContent.Name]['plural']
|
||||||
|
|
||||||
|
|
||||||
def test_system_information(flask_client):
|
def test_system_information(flask_client, settings):
|
||||||
Settings().setValue('api/authentication enabled', False)
|
Settings().setValue('api/authentication enabled', False)
|
||||||
res = flask_client.get('/api/v2/core/system').get_json()
|
res = flask_client.get('/api/v2/core/system').get_json()
|
||||||
assert res['websocket_port'] > 0
|
assert res['websocket_port'] > 0
|
||||||
@ -53,12 +53,12 @@ def test_login_without_data_returns_400(flask_client):
|
|||||||
assert res.status_code == 400
|
assert res.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_login_with_invalid_credetials_returns_401(flask_client):
|
def test_login_with_invalid_credetials_returns_401(flask_client, settings):
|
||||||
res = flask_client.post('/api/v2/core/login', json=dict(username='openlp', password='invalid'))
|
res = flask_client.post('/api/v2/core/login', json=dict(username='openlp', password='invalid'))
|
||||||
assert res.status_code == 401
|
assert res.status_code == 401
|
||||||
|
|
||||||
|
|
||||||
def test_login_with_valid_credetials_returns_token(flask_client):
|
def test_login_with_valid_credetials_returns_token(flask_client, settings):
|
||||||
Registry().register('authentication_token', 'foobar')
|
Registry().register('authentication_token', 'foobar')
|
||||||
res = flask_client.post('/api/v2/core/login', json=dict(username='openlp', password='password'))
|
res = flask_client.post('/api/v2/core/login', json=dict(username='openlp', password='password'))
|
||||||
assert res.status_code == 200
|
assert res.status_code == 200
|
||||||
@ -77,7 +77,7 @@ def test_retrieving_image(flask_client):
|
|||||||
assert res['binary_image'] != ''
|
assert res['binary_image'] != ''
|
||||||
|
|
||||||
|
|
||||||
def test_toggle_display_requires_login(flask_client):
|
def test_toggle_display_requires_login(flask_client, settings):
|
||||||
Settings().setValue('api/authentication enabled', True)
|
Settings().setValue('api/authentication enabled', True)
|
||||||
res = flask_client.post('/api/v2/core/display')
|
res = flask_client.post('/api/v2/core/display')
|
||||||
Settings().setValue('api/authentication enabled', False)
|
Settings().setValue('api/authentication enabled', False)
|
||||||
@ -89,19 +89,19 @@ def test_toggle_display_does_not_allow_get(flask_client):
|
|||||||
assert res.status_code == 405
|
assert res.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
def test_toggle_display_invalid_action(flask_client):
|
def test_toggle_display_invalid_action(flask_client, settings):
|
||||||
res = flask_client.post('/api/v2/core/display', json={'display': 'foo'})
|
res = flask_client.post('/api/v2/core/display', json={'display': 'foo'})
|
||||||
assert res.status_code == 400
|
assert res.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_toggle_display_valid_action_updates_controller(flask_client):
|
def test_toggle_display_valid_action_updates_controller(flask_client, settings):
|
||||||
class FakeController:
|
class FakeController:
|
||||||
class Emitter:
|
class Emitter:
|
||||||
def emit(self, value):
|
def emit(self, value):
|
||||||
self.set = value
|
self.set = value
|
||||||
slidecontroller_toggle_display = Emitter()
|
slidecontroller_toggle_display = Emitter()
|
||||||
controller = FakeController()
|
controller = FakeController()
|
||||||
Registry.create().register('live_controller', controller)
|
Registry().register('live_controller', controller)
|
||||||
res = flask_client.post('/api/v2/core/display', json={'display': 'show'})
|
res = flask_client.post('/api/v2/core/display', json={'display': 'show'})
|
||||||
assert res.status_code == 204
|
assert res.status_code == 204
|
||||||
assert controller.slidecontroller_toggle_display.set == 'show'
|
assert controller.slidecontroller_toggle_display.set == 'show'
|
||||||
|
@ -5,52 +5,52 @@ from openlp.core.common.registry import Registry
|
|||||||
from openlp.core.common.settings import Settings
|
from openlp.core.common.settings import Settings
|
||||||
|
|
||||||
|
|
||||||
def test_retrieve_service_items(flask_client):
|
def test_retrieve_service_items(flask_client, settings):
|
||||||
pytest.skip()
|
pytest.skip()
|
||||||
res = flask_client.get('/api/v2/service/items').get_json()
|
res = flask_client.get('/api/v2/service/items').get_json()
|
||||||
assert len(res) == 0
|
assert len(res) == 0
|
||||||
|
|
||||||
|
|
||||||
def test_service_set_requires_login(flask_client):
|
def test_service_set_requires_login(flask_client, settings):
|
||||||
Settings().setValue('api/authentication enabled', True)
|
Settings().setValue('api/authentication enabled', True)
|
||||||
res = flask_client.post('/api/v2/service/show', json=dict())
|
res = flask_client.post('/api/v2/service/show', json=dict())
|
||||||
Settings().setValue('api/authentication enabled', False)
|
Settings().setValue('api/authentication enabled', False)
|
||||||
assert res.status_code == 401
|
assert res.status_code == 401
|
||||||
|
|
||||||
|
|
||||||
def test_service_set_does_not_accept_get(flask_client):
|
def test_service_set_does_not_accept_get(flask_client, settings):
|
||||||
res = flask_client.get('/api/v2/service/show')
|
res = flask_client.get('/api/v2/service/show')
|
||||||
assert res.status_code == 405
|
assert res.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
def test_service_set_calls_service_manager(flask_client):
|
def test_service_set_calls_service_manager(flask_client, settings):
|
||||||
fake_service_manager = MagicMock()
|
fake_service_manager = MagicMock()
|
||||||
Registry.create().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.set_item.assert_called_once_with(400)
|
||||||
|
|
||||||
|
|
||||||
def test_service_direction_requires_login(flask_client):
|
def test_service_direction_requires_login(flask_client, settings):
|
||||||
Settings().setValue('api/authentication enabled', True)
|
Settings().setValue('api/authentication enabled', True)
|
||||||
res = flask_client.post('/api/v2/service/progress', json=dict())
|
res = flask_client.post('/api/v2/service/progress', json=dict())
|
||||||
Settings().setValue('api/authentication enabled', False)
|
Settings().setValue('api/authentication enabled', False)
|
||||||
assert res.status_code == 401
|
assert res.status_code == 401
|
||||||
|
|
||||||
|
|
||||||
def test_service_direction_does_not_accept_get(flask_client):
|
def test_service_direction_does_not_accept_get(flask_client, settings):
|
||||||
res = flask_client.get('/api/v2/service/progress')
|
res = flask_client.get('/api/v2/service/progress')
|
||||||
assert res.status_code == 405
|
assert res.status_code == 405
|
||||||
|
|
||||||
|
|
||||||
def test_service_direction_does_fails_on_wrong_data(flask_client):
|
def test_service_direction_does_fails_on_wrong_data(flask_client, settings):
|
||||||
res = flask_client.post('/api/v2/service/progress', json=dict(action='foo'))
|
res = flask_client.post('/api/v2/service/progress', json=dict(action='foo'))
|
||||||
assert res.status_code == 400
|
assert res.status_code == 400
|
||||||
|
|
||||||
|
|
||||||
def test_service_direction_calls_service_manager(flask_client):
|
def test_service_direction_calls_service_manager(flask_client, settings):
|
||||||
fake_service_manager = MagicMock()
|
fake_service_manager = MagicMock()
|
||||||
Registry.create().register('service_manager', fake_service_manager)
|
Registry().register('service_manager', fake_service_manager)
|
||||||
res = flask_client.post('/api/v2/service/progress', json=dict(action='next'))
|
res = flask_client.post('/api/v2/service/progress', json=dict(action='next'))
|
||||||
assert res.status_code == 204
|
assert res.status_code == 204
|
||||||
fake_service_manager.servicemanager_next_item.emit.assert_called_once()
|
fake_service_manager.servicemanager_next_item.emit.assert_called_once()
|
||||||
|
@ -32,16 +32,15 @@ from openlp.core.common.applocation import AppLocation
|
|||||||
FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3']
|
FILE_LIST = ['file1', 'file2', 'file3.txt', 'file4.txt', 'file5.mp3', 'file6.mp3']
|
||||||
|
|
||||||
|
|
||||||
@patch('openlp.core.common.applocation.Settings')
|
|
||||||
@patch('openlp.core.common.applocation.AppLocation.get_directory')
|
@patch('openlp.core.common.applocation.AppLocation.get_directory')
|
||||||
@patch('openlp.core.common.applocation.create_paths')
|
@patch('openlp.core.common.applocation.create_paths')
|
||||||
@patch('openlp.core.common.applocation.os')
|
@patch('openlp.core.common.applocation.os')
|
||||||
def test_get_data_path(mocked_os, mocked_create_paths, mocked_get_directory, MockSettings):
|
def test_get_data_path(mocked_os, mocked_create_paths, mocked_get_directory, mock_settings):
|
||||||
"""
|
"""
|
||||||
Test the AppLocation.get_data_path() method
|
Test the AppLocation.get_data_path() method
|
||||||
"""
|
"""
|
||||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_directory()
|
||||||
MockSettings.return_value.contains.return_value = False
|
mock_settings.contains.return_value = False
|
||||||
mocked_get_directory.return_value = Path('tests', 'dir')
|
mocked_get_directory.return_value = Path('tests', 'dir')
|
||||||
mocked_create_paths.return_value = True
|
mocked_create_paths.return_value = True
|
||||||
mocked_os.path.normpath.return_value = Path('tests', 'dir')
|
mocked_os.path.normpath.return_value = Path('tests', 'dir')
|
||||||
@ -50,27 +49,26 @@ def test_get_data_path(mocked_os, mocked_create_paths, mocked_get_directory, Moc
|
|||||||
data_path = AppLocation.get_data_path()
|
data_path = AppLocation.get_data_path()
|
||||||
|
|
||||||
# THEN: check that all the correct methods were called, and the result is correct
|
# THEN: check that all the correct methods were called, and the result is correct
|
||||||
MockSettings.return_value.contains.assert_called_with('advanced/data path')
|
mock_settings.contains.assert_called_with('advanced/data path')
|
||||||
mocked_get_directory.assert_called_with(AppLocation.DataDir)
|
mocked_get_directory.assert_called_with(AppLocation.DataDir)
|
||||||
mocked_create_paths.assert_called_with(Path('tests', 'dir'))
|
mocked_create_paths.assert_called_with(Path('tests', 'dir'))
|
||||||
assert data_path == Path('tests', 'dir'), 'Result should be "tests/dir"'
|
assert data_path == Path('tests', 'dir'), 'Result should be "tests/dir"'
|
||||||
|
|
||||||
|
|
||||||
@patch('openlp.core.common.applocation.Settings')
|
def test_get_data_path_with_custom_location(mock_settings):
|
||||||
def test_get_data_path_with_custom_location(MockSettings):
|
|
||||||
"""
|
"""
|
||||||
Test the AppLocation.get_data_path() method when a custom location is set in the settings
|
Test the AppLocation.get_data_path() method when a custom location is set in the settings
|
||||||
"""
|
"""
|
||||||
# GIVEN: A mocked out Settings class which returns a custom data location
|
# GIVEN: A mocked out Settings class which returns a custom data location
|
||||||
MockSettings.return_value.contains.return_value = True
|
mock_settings.contains.return_value = True
|
||||||
MockSettings.return_value.value.return_value = Path('custom', 'dir')
|
mock_settings.value.return_value = Path('custom', 'dir')
|
||||||
|
|
||||||
# WHEN: we call AppLocation.get_data_path()
|
# WHEN: we call AppLocation.get_data_path()
|
||||||
data_path = AppLocation.get_data_path()
|
data_path = AppLocation.get_data_path()
|
||||||
|
|
||||||
# THEN: the mocked Settings methods were called and the value returned was our set up value
|
# 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')
|
mock_settings.contains.assert_called_with('advanced/data path')
|
||||||
MockSettings.return_value.value.assert_called_with('advanced/data path')
|
mock_settings.value.assert_called_with('advanced/data path')
|
||||||
assert data_path == Path('custom', 'dir'), 'Result should be "custom/dir"'
|
assert data_path == Path('custom', 'dir'), 'Result should be "custom/dir"'
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
|
|
||||||
from openlp.core.common.httputils import ProxyMode, download_file, get_proxy_settings, get_url_file_size, \
|
from openlp.core.common.httputils import ProxyMode, download_file, get_proxy_settings, get_url_file_size, \
|
||||||
get_user_agent, get_web_page
|
get_user_agent, get_web_page
|
||||||
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.common.settings import Settings
|
from openlp.core.common.settings import Settings
|
||||||
from tests.helpers.testmixin import TestMixin
|
from tests.helpers.testmixin import TestMixin
|
||||||
|
|
||||||
@ -39,6 +40,8 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||||||
"""
|
"""
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.tempfile = os.path.join(tempfile.gettempdir(), 'testfile')
|
self.tempfile = os.path.join(tempfile.gettempdir(), 'testfile')
|
||||||
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if os.path.isfile(self.tempfile):
|
if os.path.isfile(self.tempfile):
|
||||||
@ -137,7 +140,7 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||||||
mocked_requests.get.assert_called_once_with(fake_url, headers={'User-Agent': 'user_agent'},
|
mocked_requests.get.assert_called_once_with(fake_url, headers={'User-Agent': 'user_agent'},
|
||||||
proxies=None, timeout=30.0)
|
proxies=None, timeout=30.0)
|
||||||
mocked_get_user_agent.assert_called_once_with()
|
mocked_get_user_agent.assert_called_once_with()
|
||||||
assert MockRegistry.call_count == 0, 'The Registry() object should have never been called'
|
assert MockRegistry.call_count == 1, 'The Registry() object should have been called once'
|
||||||
assert returned_page == 'text', 'The returned page should be the mock object'
|
assert returned_page == 'text', 'The returned page should be the mock object'
|
||||||
|
|
||||||
@patch('openlp.core.common.httputils.requests')
|
@patch('openlp.core.common.httputils.requests')
|
||||||
@ -245,35 +248,10 @@ class TestHttpUtils(TestCase, TestMixin):
|
|||||||
class TestGetProxySettings(TestCase, TestMixin):
|
class TestGetProxySettings(TestCase, TestMixin):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.build_settings()
|
self.build_settings()
|
||||||
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
self.addCleanup(self.destroy_settings)
|
self.addCleanup(self.destroy_settings)
|
||||||
|
|
||||||
@patch('openlp.core.common.httputils.Settings')
|
|
||||||
def test_mode_arg_specified(self, mocked_settings):
|
|
||||||
"""
|
|
||||||
Test that the argument is used rather than reading the 'advanced/proxy mode' setting
|
|
||||||
"""
|
|
||||||
# GIVEN: Mocked settings
|
|
||||||
|
|
||||||
# WHEN: Calling `get_proxy_settings` with the mode arg specified
|
|
||||||
get_proxy_settings(mode=ProxyMode.NO_PROXY)
|
|
||||||
|
|
||||||
# THEN: The mode arg should have been used rather than looking it up in the settings
|
|
||||||
mocked_settings().value.assert_not_called()
|
|
||||||
|
|
||||||
@patch('openlp.core.common.httputils.Settings')
|
|
||||||
def test_mode_incorrect_arg_specified(self, mocked_settings):
|
|
||||||
"""
|
|
||||||
Test that the system settings are used when the mode arg specieied is invalid
|
|
||||||
"""
|
|
||||||
# GIVEN: Mocked settings
|
|
||||||
|
|
||||||
# WHEN: Calling `get_proxy_settings` with an invalid mode arg specified
|
|
||||||
result = get_proxy_settings(mode='qwerty')
|
|
||||||
|
|
||||||
# THEN: An None should be returned
|
|
||||||
mocked_settings().value.assert_not_called()
|
|
||||||
assert result is None
|
|
||||||
|
|
||||||
def test_no_proxy_mode(self):
|
def test_no_proxy_mode(self):
|
||||||
"""
|
"""
|
||||||
Test that a dictionary with http and https values are set to None is returned, when `NO_PROXY` mode is specified
|
Test that a dictionary with http and https values are set to None is returned, when `NO_PROXY` mode is specified
|
||||||
@ -352,3 +330,30 @@ class TestGetProxySettings(TestCase, TestMixin):
|
|||||||
|
|
||||||
# THEN: The returned value should be the proxy servers set to None
|
# THEN: The returned value should be the proxy servers set to None
|
||||||
assert result == {'http': None, 'https': None}
|
assert result == {'http': None, 'https': None}
|
||||||
|
|
||||||
|
|
||||||
|
def test_mode_arg_specified(mock_settings):
|
||||||
|
"""
|
||||||
|
Test that the argument is used rather than reading the 'advanced/proxy mode' setting
|
||||||
|
"""
|
||||||
|
# GIVEN: Mocked settings
|
||||||
|
|
||||||
|
# WHEN: Calling `get_proxy_settings` with the mode arg specified
|
||||||
|
get_proxy_settings(mode=ProxyMode.NO_PROXY)
|
||||||
|
|
||||||
|
# THEN: The mode arg should have been used rather than looking it up in the settings
|
||||||
|
mock_settings.value.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
def test_mode_incorrect_arg_specified(mock_settings):
|
||||||
|
"""
|
||||||
|
Test that the system settings are used when the mode arg specieied is invalid
|
||||||
|
"""
|
||||||
|
# GIVEN: Mocked settings
|
||||||
|
|
||||||
|
# WHEN: Calling `get_proxy_settings` with an invalid mode arg specified
|
||||||
|
result = get_proxy_settings(mode='qwerty')
|
||||||
|
|
||||||
|
# THEN: An None should be returned
|
||||||
|
mock_settings.value.assert_not_called()
|
||||||
|
assert result is None
|
||||||
|
@ -155,7 +155,7 @@ def test_check_same_instance():
|
|||||||
assert first_instance is second_instance, 'Two UiStrings objects should be the same instance'
|
assert first_instance is second_instance, 'Two UiStrings objects should be the same instance'
|
||||||
|
|
||||||
|
|
||||||
def test_get_language_from_settings():
|
def test_get_language_from_settings(settings):
|
||||||
assert LanguageManager.get_language() == 'en'
|
assert LanguageManager.get_language() == 'en'
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ Package to test the openlp.core.ui.advancedtab package.
|
|||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.ui.advancedtab import AdvancedTab
|
from openlp.core.ui.advancedtab import AdvancedTab
|
||||||
from openlp.core.ui.settingsform import SettingsForm
|
from openlp.core.ui.settingsform import SettingsForm
|
||||||
from tests.helpers.testmixin import TestMixin
|
from tests.helpers.testmixin import TestMixin
|
||||||
@ -36,6 +37,7 @@ class TestAdvancedTab(TestCase, TestMixin):
|
|||||||
Set up a few things for the tests
|
Set up a few things for the tests
|
||||||
"""
|
"""
|
||||||
Registry.create()
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def test_creation(self):
|
def test_creation(self):
|
||||||
"""
|
"""
|
||||||
|
@ -21,19 +21,13 @@
|
|||||||
"""
|
"""
|
||||||
Package to test the openlp.core.utils.__init__ package.
|
Package to test the openlp.core.utils.__init__ package.
|
||||||
"""
|
"""
|
||||||
from unittest import TestCase
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from openlp.core.common.httputils import CONNECTION_RETRIES, get_web_page
|
from openlp.core.common.httputils import CONNECTION_RETRIES, get_web_page
|
||||||
from tests.helpers.testmixin import TestMixin
|
|
||||||
|
|
||||||
|
|
||||||
class TestFirstTimeWizard(TestMixin, TestCase):
|
|
||||||
"""
|
|
||||||
Test First Time Wizard import functions
|
|
||||||
"""
|
|
||||||
@patch('openlp.core.common.httputils.requests')
|
@patch('openlp.core.common.httputils.requests')
|
||||||
def test_webpage_connection_retry(self, mocked_requests):
|
def test_webpage_connection_retry(mocked_requests, mock_settings):
|
||||||
"""
|
"""
|
||||||
Test get_web_page will attempt CONNECTION_RETRIES+1 connections - bug 1409031
|
Test get_web_page will attempt CONNECTION_RETRIES+1 connections - bug 1409031
|
||||||
"""
|
"""
|
||||||
|
@ -31,6 +31,7 @@ from PyQt5 import QtCore, QtWidgets
|
|||||||
from openlp.core.state import State
|
from openlp.core.state import State
|
||||||
from openlp.core.common.i18n import UiStrings
|
from openlp.core.common.i18n import UiStrings
|
||||||
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.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
from tests.helpers.testmixin import TestMixin
|
from tests.helpers.testmixin import TestMixin
|
||||||
@ -64,6 +65,7 @@ class TestMainWindow(TestCase, TestMixin):
|
|||||||
self.app.process_events = MagicMock()
|
self.app.process_events = MagicMock()
|
||||||
self.app.args = []
|
self.app.args = []
|
||||||
Registry().register('application', self.app)
|
Registry().register('application', self.app)
|
||||||
|
Registry().register('settings', Settings())
|
||||||
Registry().set_flag('no_web_server', True)
|
Registry().set_flag('no_web_server', True)
|
||||||
self.add_toolbar_action_patcher = patch('openlp.core.ui.mainwindow.create_action')
|
self.add_toolbar_action_patcher = patch('openlp.core.ui.mainwindow.create_action')
|
||||||
self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start()
|
self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start()
|
||||||
@ -161,8 +163,8 @@ class TestMainWindow(TestCase, TestMixin):
|
|||||||
# WHEN: you check the started functions
|
# WHEN: you check the started functions
|
||||||
|
|
||||||
# THEN: the following registry functions should have been registered
|
# THEN: the following registry functions should have been registered
|
||||||
expected_service_list = ['application', 'main_window', 'http_server', 'authentication_token', 'settings_form',
|
expected_service_list = ['application', 'settings', 'main_window', 'http_server', 'authentication_token',
|
||||||
'service_manager', 'theme_manager', 'projector_manager']
|
'settings_form', 'service_manager', 'theme_manager', 'projector_manager']
|
||||||
expected_functions_list = ['bootstrap_initialise', 'bootstrap_post_set_up', 'bootstrap_completion',
|
expected_functions_list = ['bootstrap_initialise', 'bootstrap_post_set_up', 'bootstrap_completion',
|
||||||
'theme_update_global', 'config_screen_changed']
|
'theme_update_global', 'config_screen_changed']
|
||||||
assert list(self.registry.service_list.keys()) == expected_service_list, \
|
assert list(self.registry.service_list.keys()) == expected_service_list, \
|
||||||
|
@ -47,6 +47,8 @@ class TestImpressController(TestCase, TestMixin):
|
|||||||
self.mock_plugin = MagicMock()
|
self.mock_plugin = MagicMock()
|
||||||
self.temp_folder = mkdtemp()
|
self.temp_folder = mkdtemp()
|
||||||
self.mock_plugin.settings_section = self.temp_folder
|
self.mock_plugin.settings_section = self.temp_folder
|
||||||
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
|
@ -58,6 +58,8 @@ class TestPowerpointController(TestCase, TestMixin):
|
|||||||
self.mock_plugin = MagicMock()
|
self.mock_plugin = MagicMock()
|
||||||
self.temp_folder = mkdtemp()
|
self.temp_folder = mkdtemp()
|
||||||
self.mock_plugin.settings_section = self.temp_folder
|
self.mock_plugin.settings_section = self.temp_folder
|
||||||
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
|
@ -26,6 +26,8 @@ import shutil
|
|||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from openlp.core.common.registry import Registry
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
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
|
||||||
from openlp.plugins.songs.lib.db import Author, AuthorType, Book, Song
|
from openlp.plugins.songs.lib.db import Author, AuthorType, Book, Song
|
||||||
@ -42,6 +44,8 @@ class TestDB(TestCase):
|
|||||||
Setup for tests
|
Setup for tests
|
||||||
"""
|
"""
|
||||||
self.tmp_folder = mkdtemp()
|
self.tmp_folder = mkdtemp()
|
||||||
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
"""
|
"""
|
||||||
|
@ -29,6 +29,7 @@ from PyQt5 import QtGui
|
|||||||
from openlp.core.state import State
|
from openlp.core.state import State
|
||||||
from openlp.core.common import is_macosx
|
from openlp.core.common import is_macosx
|
||||||
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.plugin import PluginStatus
|
from openlp.core.lib.plugin import PluginStatus
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
from tests.helpers.testmixin import TestMixin
|
from tests.helpers.testmixin import TestMixin
|
||||||
@ -49,6 +50,7 @@ class TestMainWindow(TestCase, TestMixin):
|
|||||||
self.app.set_normal_cursor = MagicMock()
|
self.app.set_normal_cursor = MagicMock()
|
||||||
self.app.args = []
|
self.app.args = []
|
||||||
Registry().register('application', self.app)
|
Registry().register('application', self.app)
|
||||||
|
Registry().register('settings', Settings())
|
||||||
Registry().set_flag('no_web_server', True)
|
Registry().set_flag('no_web_server', True)
|
||||||
mocked_plugin = MagicMock()
|
mocked_plugin = MagicMock()
|
||||||
mocked_plugin.status = PluginStatus.Active
|
mocked_plugin.status = PluginStatus.Active
|
||||||
|
@ -26,6 +26,7 @@ from unittest.mock import MagicMock, patch
|
|||||||
|
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
from openlp.core.lib.serviceitem import ItemCapabilities, ServiceItem
|
from openlp.core.lib.serviceitem import ItemCapabilities, ServiceItem
|
||||||
from openlp.core.ui.servicemanager import ServiceManager
|
from openlp.core.ui.servicemanager import ServiceManager
|
||||||
@ -56,6 +57,7 @@ class TestServiceManager(TestCase, TestMixin):
|
|||||||
self.setup_application()
|
self.setup_application()
|
||||||
Registry().register('application', MagicMock())
|
Registry().register('application', MagicMock())
|
||||||
Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager'))
|
Registry().register('main_window', MagicMock(service_manager_settings_section='servicemanager'))
|
||||||
|
Registry().register('settings', Settings())
|
||||||
self.service_manager = ServiceManager()
|
self.service_manager = ServiceManager()
|
||||||
self.add_toolbar_action_patcher = patch('openlp.core.ui.servicemanager.OpenLPToolbar.add_toolbar_action')
|
self.add_toolbar_action_patcher = patch('openlp.core.ui.servicemanager.OpenLPToolbar.add_toolbar_action')
|
||||||
self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start()
|
self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start()
|
||||||
|
@ -26,6 +26,7 @@ from unittest import TestCase, skipIf
|
|||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.plugins.bibles.lib.importers.http import BGExtract, BSExtract, CWExtract
|
from openlp.plugins.bibles.lib.importers.http import BGExtract, BSExtract, CWExtract
|
||||||
|
|
||||||
IS_CI = 'GITLAB_CI' in os.environ or 'APPVEYOR' in os.environ
|
IS_CI = 'GITLAB_CI' in os.environ or 'APPVEYOR' in os.environ
|
||||||
@ -42,6 +43,7 @@ class TestBibleHTTP(TestCase):
|
|||||||
Registry().register('service_list', MagicMock())
|
Registry().register('service_list', MagicMock())
|
||||||
Registry().register('application', MagicMock())
|
Registry().register('application', MagicMock())
|
||||||
Registry().register('main_window', MagicMock())
|
Registry().register('main_window', MagicMock())
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
def test_bible_gateway_extract_books(self):
|
def test_bible_gateway_extract_books(self):
|
||||||
"""
|
"""
|
||||||
|
@ -53,10 +53,11 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
'bibles/end separator': '',
|
'bibles/end separator': '',
|
||||||
}
|
}
|
||||||
Settings().extend_default_settings(bible_settings)
|
Settings().extend_default_settings(bible_settings)
|
||||||
with patch('openlp.core.common.applocation.Settings') as mocked_class, \
|
with patch('openlp.core.common.applocation.AppLocation.get_section_data_path') as mocked_get_data_path, \
|
||||||
patch('openlp.core.common.applocation.AppLocation.get_section_data_path') as mocked_get_data_path, \
|
|
||||||
patch('openlp.core.common.applocation.AppLocation.get_files') as mocked_get_files:
|
patch('openlp.core.common.applocation.AppLocation.get_files') as mocked_get_files:
|
||||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_files()
|
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_files()
|
||||||
|
mocked_class = MagicMock()
|
||||||
|
Registry().register('settings', mocked_class.return_value)
|
||||||
mocked_settings = mocked_class.return_value
|
mocked_settings = mocked_class.return_value
|
||||||
mocked_settings.contains.return_value = False
|
mocked_settings.contains.return_value = False
|
||||||
mocked_get_files.return_value = ["tests.sqlite"]
|
mocked_get_files.return_value = ["tests.sqlite"]
|
||||||
|
@ -54,12 +54,11 @@ class TestBibleManager(TestCase, TestMixin):
|
|||||||
'bibles/end separator': '',
|
'bibles/end separator': '',
|
||||||
}
|
}
|
||||||
Settings().extend_default_settings(bible_settings)
|
Settings().extend_default_settings(bible_settings)
|
||||||
with patch('openlp.core.common.applocation.Settings') as mocked_class, \
|
with patch('openlp.core.common.applocation.AppLocation.get_section_data_path') as mocked_get_data_path, \
|
||||||
patch('openlp.core.common.applocation.AppLocation.get_section_data_path') as mocked_get_data_path, \
|
|
||||||
patch('openlp.core.common.applocation.AppLocation.get_files') as mocked_get_files:
|
patch('openlp.core.common.applocation.AppLocation.get_files') as mocked_get_files:
|
||||||
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_files()
|
# GIVEN: A mocked out Settings class and a mocked out AppLocation.get_files()
|
||||||
mocked_settings = mocked_class.return_value
|
mocked_class = MagicMock()
|
||||||
mocked_settings.contains.return_value = False
|
Registry().register('settings', mocked_class.return_value)
|
||||||
mocked_get_files.return_value = ["tests.sqlite"]
|
mocked_get_files.return_value = ["tests.sqlite"]
|
||||||
mocked_get_data_path.return_value = TEST_RESOURCES_PATH + "/bibles"
|
mocked_get_data_path.return_value = TEST_RESOURCES_PATH + "/bibles"
|
||||||
self.manager = BibleManager(MagicMock())
|
self.manager = BibleManager(MagicMock())
|
||||||
|
@ -83,11 +83,9 @@ def test_zeroconf_worker_stop():
|
|||||||
|
|
||||||
@patch('openlp.core.api.zeroconf.get_network_interfaces')
|
@patch('openlp.core.api.zeroconf.get_network_interfaces')
|
||||||
@patch('openlp.core.api.zeroconf.Registry')
|
@patch('openlp.core.api.zeroconf.Registry')
|
||||||
@patch('openlp.core.api.zeroconf.Settings')
|
|
||||||
@patch('openlp.core.api.zeroconf.ZeroconfWorker')
|
@patch('openlp.core.api.zeroconf.ZeroconfWorker')
|
||||||
@patch('openlp.core.api.zeroconf.run_thread')
|
@patch('openlp.core.api.zeroconf.run_thread')
|
||||||
def test_start_zeroconf(mocked_run_thread, MockedZeroconfWorker, MockedSettings, MockedRegistry,
|
def test_start_zeroconf(mocked_run_thread, MockedZeroconfWorker, MockedRegistry, mocked_get_network_interfaces):
|
||||||
mocked_get_network_interfaces):
|
|
||||||
"""Test the start_zeroconf() function"""
|
"""Test the start_zeroconf() function"""
|
||||||
# GIVEN: A whole bunch of stuff that's mocked out
|
# GIVEN: A whole bunch of stuff that's mocked out
|
||||||
mocked_get_network_interfaces.return_value = {
|
mocked_get_network_interfaces.return_value = {
|
||||||
@ -100,7 +98,7 @@ def test_start_zeroconf(mocked_run_thread, MockedZeroconfWorker, MockedSettings,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MockedRegistry.return_value.get_flag.return_value = False
|
MockedRegistry.return_value.get_flag.return_value = False
|
||||||
MockedSettings.return_value.value.side_effect = [8000, 8001]
|
MockedRegistry.settings.return_value.value.side_effect = [8000, 8001]
|
||||||
mocked_worker = MagicMock()
|
mocked_worker = MagicMock()
|
||||||
MockedZeroconfWorker.return_value = mocked_worker
|
MockedZeroconfWorker.return_value = mocked_worker
|
||||||
|
|
||||||
|
@ -31,6 +31,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.core.lib.db import upgrade_db
|
from openlp.core.lib.db import upgrade_db
|
||||||
from openlp.core.projectors import upgrade
|
from openlp.core.projectors import upgrade
|
||||||
from openlp.core.projectors.constants import PJLINK_PORT
|
from openlp.core.projectors.constants import PJLINK_PORT
|
||||||
@ -143,6 +144,7 @@ class TestProjectorDB(TestCase, TestMixin):
|
|||||||
self.app.set_normal_cursor = MagicMock()
|
self.app.set_normal_cursor = MagicMock()
|
||||||
self.app.args = []
|
self.app.args = []
|
||||||
Registry().register('application', self.app)
|
Registry().register('application', self.app)
|
||||||
|
Registry().register('settings', Settings())
|
||||||
Registry().set_flag('no_web_server', True)
|
Registry().set_flag('no_web_server', True)
|
||||||
# Mock classes and methods used by mainwindow.
|
# Mock classes and methods used by mainwindow.
|
||||||
with patch('openlp.core.ui.mainwindow.SettingsForm'), \
|
with patch('openlp.core.ui.mainwindow.SettingsForm'), \
|
||||||
|
@ -27,6 +27,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.core.projectors.db import Projector, ProjectorDB
|
from openlp.core.projectors.db import Projector, ProjectorDB
|
||||||
from openlp.core.projectors.editform import ProjectorEditForm
|
from openlp.core.projectors.editform import ProjectorEditForm
|
||||||
from tests.helpers.testmixin import TestMixin
|
from tests.helpers.testmixin import TestMixin
|
||||||
@ -46,6 +47,7 @@ class TestProjectorEditForm(TestCase, TestMixin):
|
|||||||
self.setup_application()
|
self.setup_application()
|
||||||
self.build_settings()
|
self.build_settings()
|
||||||
Registry.create()
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
||||||
if os.path.exists(TEST_DB):
|
if os.path.exists(TEST_DB):
|
||||||
os.unlink(TEST_DB)
|
os.unlink(TEST_DB)
|
||||||
|
@ -31,6 +31,7 @@ from unittest.mock import patch
|
|||||||
from PyQt5.QtWidgets import QDialog
|
from PyQt5.QtWidgets import QDialog
|
||||||
|
|
||||||
from openlp.core.common.registry import Registry
|
from openlp.core.common.registry import Registry
|
||||||
|
from openlp.core.common.settings import Settings
|
||||||
from openlp.core.projectors.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
|
from openlp.core.projectors.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
|
||||||
from openlp.core.projectors.db import Projector, ProjectorDB
|
from openlp.core.projectors.db import Projector, ProjectorDB
|
||||||
from openlp.core.projectors.sourceselectform import SourceSelectSingle, source_group
|
from openlp.core.projectors.sourceselectform import SourceSelectSingle, source_group
|
||||||
@ -65,6 +66,8 @@ class ProjectorSourceFormTest(TestCase, TestMixin):
|
|||||||
self.setup_application()
|
self.setup_application()
|
||||||
self.build_settings()
|
self.build_settings()
|
||||||
Registry.create()
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
|
|
||||||
# Do not try to recreate if we've already been created from a previous test
|
# Do not try to recreate if we've already been created from a previous test
|
||||||
if not hasattr(self, 'projectordb'):
|
if not hasattr(self, 'projectordb'):
|
||||||
self.projectordb = ProjectorDB()
|
self.projectordb = ProjectorDB()
|
||||||
|
@ -26,6 +26,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.core.projectors.db import ProjectorDB
|
from openlp.core.projectors.db import ProjectorDB
|
||||||
from openlp.core.projectors.editform import ProjectorEditForm
|
from openlp.core.projectors.editform import ProjectorEditForm
|
||||||
from openlp.core.projectors.manager import ProjectorManager
|
from openlp.core.projectors.manager import ProjectorManager
|
||||||
@ -44,6 +45,7 @@ class TestProjectorManager(TestCase, TestMixin):
|
|||||||
self.setup_application()
|
self.setup_application()
|
||||||
self.build_settings()
|
self.build_settings()
|
||||||
Registry.create()
|
Registry.create()
|
||||||
|
Registry().register('settings', Settings())
|
||||||
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
with patch('openlp.core.projectors.db.init_url') as mocked_init_url:
|
||||||
if os.path.exists(TEST_DB):
|
if os.path.exists(TEST_DB):
|
||||||
os.unlink(TEST_DB)
|
os.unlink(TEST_DB)
|
||||||
|
Loading…
Reference in New Issue
Block a user