openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #33915
[Merge] lp:~phill-ridout/openlp/fixes-II into lp:openlp
Phill has proposed merging lp:~phill-ridout/openlp/fixes-II into lp:openlp.
Commit message:
Just to trigger the tests :-)
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/fixes-II/+merge/366949
--
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/fixes-II into lp:openlp.
=== modified file 'openlp/core/app.py'
--- openlp/core/app.py 2019-05-01 19:22:01 +0000
+++ openlp/core/app.py 2019-05-04 18:26:39 +0000
@@ -287,12 +287,12 @@
return QtWidgets.QApplication.event(self, event)
-def parse_options(args=None):
+def parse_options():
"""
Parse the command line arguments
- :param args: list of command line arguments
- :return: a tuple of parsed options of type optparse.Value and a list of remaining argsZ
+ :return: An :object:`argparse.Namespace` insatnce containing the parsed args.
+ :rtype: argparse.Namespace
"""
# Set up command line options.
parser = argparse.ArgumentParser(prog='openlp')
@@ -307,9 +307,9 @@
dir_name=os.path.join('<AppDir>', '..', '..')))
parser.add_argument('-w', '--no-web-server', dest='no_web_server', action='store_true',
help='Turn off the Web and Socket Server ')
- parser.add_argument('rargs', nargs='?', default=[])
- # Parse command line options and deal with them. Use args supplied pragmatically if possible.
- return parser.parse_args(args) if args else parser.parse_args()
+ parser.add_argument('rargs', nargs='*', default=[])
+ # Parse command line options and deal with them.
+ return parser.parse_args()
def set_up_logging(log_path):
@@ -328,13 +328,11 @@
print('Logging to: {name}'.format(name=file_path))
-def main(args=None):
+def main():
"""
The main function which parses command line options and then runs
-
- :param args: Some args
"""
- args = parse_options(args)
+ args = parse_options()
qt_args = ['--disable-web-security']
# qt_args = []
if args and args.loglevel.lower() in ['d', 'debug']:
=== modified file 'openlp/core/common/__init__.py'
--- openlp/core/common/__init__.py 2019-04-13 13:00:22 +0000
+++ openlp/core/common/__init__.py 2019-05-04 18:26:39 +0000
@@ -134,8 +134,8 @@
importlib.import_module(module_name)
except (ImportError, OSError):
# On some platforms importing vlc.py might cause OSError exceptions. (e.g. Mac OS X)
- log.warning('Failed to import {module_name} on path {extension_path}'
- .format(module_name=module_name, extension_path=extension_path))
+ log.exception('Failed to import {module_name} on path {extension_path}'
+ .format(module_name=module_name, extension_path=extension_path))
def path_to_module(path):
@@ -463,8 +463,8 @@
Utility function to incrementally detect the file encoding.
:param openlp.core.common.path.Path file_path: Filename for the file to determine the encoding for.
- :return: A dict with the keys 'encoding' and 'confidence'
- :rtype: dict[str, float]
+ :return: The name of the encoding detected
+ :rtype: str
"""
detector = UniversalDetector()
try:
@@ -477,7 +477,7 @@
except OSError:
log.exception('Error detecting file encoding')
finally:
- return detector.close()
+ return detector.close()['encoding']
def normalize_str(irregular_string):
=== modified file 'openlp/core/display/window.py'
--- openlp/core/display/window.py 2019-04-13 13:00:22 +0000
+++ openlp/core/display/window.py 2019-05-04 18:26:39 +0000
@@ -180,7 +180,7 @@
"""
Set the URL of the webview
- :param str url: The URL to set
+ :param QtCore.QUrl | str url: The URL to set
"""
if not isinstance(url, QtCore.QUrl):
url = QtCore.QUrl(url)
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2019-04-28 19:21:23 +0000
+++ openlp/core/lib/mediamanageritem.py 2019-05-04 18:26:39 +0000
@@ -29,7 +29,6 @@
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties
-from openlp.core.common.path import path_to_str, str_to_path
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import ServiceItemContext
@@ -333,7 +332,7 @@
self.validate_and_load(file_paths)
self.application.set_normal_cursor()
- def load_file(self, data):
+ def handle_mime_data(self, data):
"""
Turn file from Drag and Drop into an array so the Validate code can run it.
@@ -379,11 +378,11 @@
duplicates_found = False
files_added = False
for file_path in file_paths:
- if path_to_str(file_path) in full_list:
+ if file_path in full_list:
duplicates_found = True
else:
files_added = True
- full_list.append(path_to_str(file_path))
+ full_list.append(file_path)
if full_list and files_added:
if target_group is None:
self.list_view.clear()
@@ -416,8 +415,8 @@
file_paths = []
for index in range(self.list_view.count()):
list_item = self.list_view.item(index)
- filename = list_item.data(QtCore.Qt.UserRole)
- file_paths.append(str_to_path(filename))
+ file_path = list_item.data(QtCore.Qt.UserRole)
+ file_paths.append(file_path)
return file_paths
def load_list(self, load_list, target_group):
=== modified file 'openlp/core/lib/theme.py'
--- openlp/core/lib/theme.py 2019-04-13 13:00:22 +0000
+++ openlp/core/lib/theme.py 2019-05-04 18:26:39 +0000
@@ -333,7 +333,7 @@
else:
# make string value unicode
if not isinstance(value, str):
- value = str(str(value), 'utf-8')
+ value = str(value, 'utf-8')
# None means an empty string so lets have one.
if value == 'None':
value = ''
=== modified file 'openlp/core/server.py'
--- openlp/core/server.py 2019-04-13 13:00:22 +0000
+++ openlp/core/server.py 2019-05-04 18:26:39 +0000
@@ -22,6 +22,7 @@
from PyQt5 import QtCore, QtNetwork
from openlp.core.common.mixins import LogMixin
+from openlp.core.common.path import Path
from openlp.core.common.registry import Registry
@@ -97,7 +98,7 @@
msg = self.in_stream.readLine()
if msg:
self.log_debug("socket msg = " + msg)
- Registry().get('service_manager').on_load_service_clicked(msg)
+ Registry().get('service_manager').load_service(Path(msg))
def close_server(self):
"""
=== modified file 'openlp/core/ui/firsttimewizard.py'
--- openlp/core/ui/firsttimewizard.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/firsttimewizard.py 2019-05-04 18:26:39 +0000
@@ -78,7 +78,7 @@
"""
nominal_width = 141 # Icon width of 133 + 4 each side
max_items_per_row = self.viewport().width() // nominal_width or 1 # or 1 to avoid divide by 0 errors
- col_size = (self.viewport().width() - 1) / max_items_per_row
+ col_size = (self.viewport().width() - 1) // max_items_per_row
self.setGridSize(QtCore.QSize(col_size, 140))
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/mainwindow.py 2019-05-04 18:26:39 +0000
@@ -22,7 +22,7 @@
"""
This is the main window, where all the action happens.
"""
-import sys
+import os
from datetime import datetime
from distutils import dir_util
from distutils.errors import DistutilsFileError
@@ -475,7 +475,6 @@
super(MainWindow, self).__init__()
Registry().register('main_window', self)
self.clipboard = self.application.clipboard()
- self.arguments = ''.join(self.application.args)
# Set up settings sections for the main application (not for use by plugins).
self.ui_settings_section = 'user interface'
self.general_settings_section = 'core'
@@ -632,8 +631,8 @@
# if self.live_controller.display.isVisible():
# self.live_controller.display.setFocus()
self.activateWindow()
- if self.arguments:
- self.open_cmd_line_files(self.arguments)
+ if self.application.args:
+ self.open_cmd_line_files(self.application.args)
elif Settings().value(self.general_settings_section + '/auto open'):
self.service_manager_contents.load_last_file()
# This will store currently used layout preset so it remains enabled on next startup.
@@ -1339,7 +1338,7 @@
self.application.set_normal_cursor()
self.log_exception('Data copy failed {err}'.format(err=str(why)))
err_text = translate('OpenLP.MainWindow',
- 'OpenLP Data directory copy failed\n\n{err}').format(err=str(why)),
+ 'OpenLP Data directory copy failed\n\n{err}').format(err=str(why))
QtWidgets.QMessageBox.critical(self, translate('OpenLP.MainWindow', 'New Data Directory Error'),
err_text,
QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Ok))
@@ -1354,11 +1353,13 @@
settings.remove('advanced/data path')
self.application.set_normal_cursor()
- def open_cmd_line_files(self, filename):
+ def open_cmd_line_files(self, args):
"""
Open files passed in through command line arguments
+
+ :param list[str] args: List of remaining positionall arguments
"""
- if not isinstance(filename, str):
- filename = str(filename, sys.getfilesystemencoding())
- if filename.endswith(('.osz', '.oszl')):
- self.service_manager_contents.load_file(Path(filename))
+ for arg in args:
+ file_name = os.path.expanduser(arg)
+ if os.path.isfile(file_name):
+ self.service_manager_contents.load_file(Path(file_name))
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/servicemanager.py 2019-05-04 18:26:39 +0000
@@ -38,7 +38,7 @@
from openlp.core.common.i18n import UiStrings, format_time, translate
from openlp.core.common.json import OpenLPJsonDecoder, OpenLPJsonEncoder
from openlp.core.common.mixins import LogMixin, RegistryProperties
-from openlp.core.common.path import Path, str_to_path
+from openlp.core.common.path import Path
from openlp.core.common.registry import Registry, RegistryBase
from openlp.core.common.settings import Settings
from openlp.core.lib import build_icon
@@ -430,11 +430,20 @@
return False
self.new_file()
- def on_load_service_clicked(self, load_file=None):
+ def on_load_service_clicked(self, checked):
+ """
+ Handle the `fileOpenItem` action
+
+ :param bool checked: Not used.
+ :rtype: None
+ """
+ self.load_service()
+
+ def load_service(self, file_path=None):
"""
Loads the service file and saves the existing one it there is one unchanged.
- :param load_file: The service file to the loaded. Will be None is from menu so selection will be required.
+ :param openlp.core.common.path.Path | None file_path: The service file to the loaded.
"""
if self.is_modified():
result = self.save_modified_service()
@@ -442,7 +451,7 @@
return False
elif result == QtWidgets.QMessageBox.Save:
self.decide_save_method()
- if not load_file:
+ if not file_path:
file_path, filter_used = FileDialog.getOpenFileName(
self.main_window,
translate('OpenLP.ServiceManager', 'Open File'),
@@ -450,8 +459,6 @@
translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz *.oszl)'))
if not file_path:
return False
- else:
- file_path = str_to_path(load_file)
Settings().setValue(self.main_window.service_manager_settings_section + '/last directory', file_path.parent)
self.load_file(file_path)
@@ -670,8 +677,9 @@
def load_file(self, file_path):
"""
- Load an existing service file
- :param file_path:
+ Load an existing service file.
+
+ :param openlp.core.common.path.Path file_path: The service file to load.
"""
if not file_path.exists():
return False
@@ -1520,12 +1528,12 @@
event.setDropAction(QtCore.Qt.CopyAction)
event.accept()
for url in link.urls():
- file_name = url.toLocalFile()
- if file_name.endswith('.osz'):
- self.on_load_service_clicked(file_name)
- elif file_name.endswith('.oszl'):
+ file_path = Path(url.toLocalFile())
+ if file_path.suffix == '.osz':
+ self.load_service(file_path)
+ elif file_path.suffix == '.oszl':
# todo correct
- self.on_load_service_clicked(file_name)
+ self.load_service(file_path)
elif link.hasText():
plugin = link.text()
item = self.service_manager_list.itemAt(event.pos())
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2019-04-13 13:00:22 +0000
+++ openlp/core/ui/slidecontroller.py 2019-05-04 18:26:39 +0000
@@ -112,7 +112,7 @@
class InfoLabel(QtWidgets.QLabel):
"""
- InfoLabel is a subclassed QLabel. Created to provide the ablilty to add a ellipsis if the text is cut off. Original
+ InfoLabel is a subclassed QLabel. Created to provide the ability to add a ellipsis if the text is cut off. Original
source: https://stackoverflow.com/questions/11446478/pyside-pyqt-truncate-text-in-qlabel-based-on-minimumsize
"""
=== modified file 'openlp/core/widgets/dialogs.py'
--- openlp/core/widgets/dialogs.py 2019-04-13 13:00:22 +0000
+++ openlp/core/widgets/dialogs.py 2019-05-04 18:26:39 +0000
@@ -35,7 +35,7 @@
:type caption: str
:type directory: openlp.core.common.path.Path
:type options: QtWidgets.QFileDialog.Options
- :rtype: tuple[openlp.core.common.path.Path, str]
+ :rtype: openlp.core.common.path.Path
"""
args, kwargs = replace_params(args, kwargs, ((2, 'directory', path_to_str),))
=== modified file 'openlp/core/widgets/layouts.py'
--- openlp/core/widgets/layouts.py 2019-04-13 13:00:22 +0000
+++ openlp/core/widgets/layouts.py 2019-05-04 18:26:39 +0000
@@ -37,7 +37,7 @@
"""
Create a layout.
- :param PyQt5.QtWidgets.QWidget parent: The parent widget, can be None.
+ :param QtWidgets.QWidget | None parent: The parent widget
:param float aspect_ratio: The aspect ratio as a float (e.g. 16.0/9.0)
"""
super().__init__(parent)
=== modified file 'openlp/core/widgets/views.py'
--- openlp/core/widgets/views.py 2019-04-13 13:00:22 +0000
+++ openlp/core/widgets/views.py 2019-05-04 18:26:39 +0000
@@ -39,7 +39,7 @@
"""
Process the data from a drag and drop operation.
- :param PyQt5.QtCore.QMimeData mime_data: The mime data from the drag and drop opperation.
+ :param QtCore.QMimeData mime_data: The mime data from the drag and drop opperation.
:return: A list of file paths that were dropped
:rtype: list[openlp.core.common.path.Path]
"""
@@ -297,7 +297,7 @@
"""
self.setAcceptDrops(True)
self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)
- Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file)
+ Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().handle_mime_data)
def clear(self, search_while_typing=False):
"""
@@ -412,7 +412,7 @@
"""
self.setAcceptDrops(True)
self.setDragDropMode(QtWidgets.QAbstractItemView.DragDrop)
- Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().load_file)
+ Registry().register_function(('%s_dnd' % self.mime_data_text), self.parent().handle_mime_data)
Registry().register_function(('%s_dnd_internal' % self.mime_data_text), self.parent().dnd_move_internal)
def mouseMoveEvent(self, event):
=== modified file 'openlp/plugins/bibles/lib/importers/csvbible.py'
--- openlp/plugins/bibles/lib/importers/csvbible.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/bibles/lib/importers/csvbible.py 2019-05-04 18:26:39 +0000
@@ -102,7 +102,7 @@
:rtype: list[namedtuple]
"""
try:
- encoding = get_file_encoding(file_path)['encoding']
+ encoding = get_file_encoding(file_path)
with file_path.open('r', encoding=encoding, newline='') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',', quotechar='"')
return [results_tuple(*line) for line in csv_reader]
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2019-05-04 18:26:39 +0000
@@ -401,10 +401,9 @@
Process a list for files either from the File Dialog or from Drag and Drop.
This method is overloaded from MediaManagerItem.
- :param files: A List of strings containing the filenames of the files to be loaded
+ :param list[openlp.core.common.path.Path] file_paths: A List of paths to be loaded
:param target_group: The QTreeWidgetItem of the group that will be the parent of the added files
"""
- file_paths = [Path(file) for file in file_paths]
self.application.set_normal_cursor()
self.load_list(file_paths, target_group)
last_dir = file_paths[0].parent
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2019-05-04 18:26:39 +0000
@@ -24,7 +24,7 @@
from PyQt5 import QtCore, QtWidgets
from openlp.core.common.i18n import UiStrings, get_natural_key, translate
-from openlp.core.common.path import path_to_str, str_to_path
+from openlp.core.common.path import path_to_str
from openlp.core.common.registry import Registry
from openlp.core.common.settings import Settings
from openlp.core.lib import ServiceItemContext, build_icon, check_item_selected, create_thumb, validate_thumb
@@ -127,7 +127,7 @@
"""
self.list_view.setIconSize(QtCore.QSize(88, 50))
file_paths = Settings().value(self.settings_section + '/presentations files')
- self.load_list([path_to_str(path) for path in file_paths], initial_load=True)
+ self.load_list(file_paths, initial_load=True)
self.populate_display_types()
def populate_display_types(self):
@@ -158,7 +158,6 @@
:param list[openlp.core.common.path.Path] file_paths: List of file paths to add to the media manager.
"""
- file_paths = [str_to_path(filename) for filename in file_paths]
current_paths = self.get_file_list()
titles = [file_path.name for file_path in current_paths]
self.application.set_busy_cursor()
@@ -175,7 +174,7 @@
if not file_path.exists():
item_name = QtWidgets.QListWidgetItem(file_name)
item_name.setIcon(UiIcons().delete)
- item_name.setData(QtCore.Qt.UserRole, path_to_str(file_path))
+ item_name.setData(QtCore.Qt.UserRole, file_path)
item_name.setToolTip(str(file_path))
self.list_view.addItem(item_name)
else:
@@ -211,7 +210,7 @@
'This type of presentation is not supported.'))
continue
item_name = QtWidgets.QListWidgetItem(file_name)
- item_name.setData(QtCore.Qt.UserRole, path_to_str(file_path))
+ item_name.setData(QtCore.Qt.UserRole, file_path)
item_name.setIcon(icon)
item_name.setToolTip(str(file_path))
self.list_view.addItem(item_name)
@@ -230,8 +229,7 @@
self.application.set_busy_cursor()
self.main_window.display_progress_bar(len(row_list))
for item in items:
- file_path = str_to_path(item.data(QtCore.Qt.UserRole))
- self.clean_up_thumbnails(file_path)
+ self.clean_up_thumbnails(item.data(QtCore.Qt.UserRole))
self.main_window.increment_progress_bar()
self.main_window.finished_progress_bar()
for row in row_list:
@@ -278,7 +276,7 @@
if len(items) > 1:
return False
if file_path is None:
- file_path = str_to_path(items[0].data(QtCore.Qt.UserRole))
+ file_path = items[0].data(QtCore.Qt.UserRole)
file_type = file_path.suffix.lower()[1:]
if not self.display_type_combo_box.currentText():
return False
@@ -293,7 +291,7 @@
service_item.theme = -1
for bitem in items:
if file_path is None:
- file_path = str_to_path(bitem.data(QtCore.Qt.UserRole))
+ file_path = bitem.data(QtCore.Qt.UserRole)
path, file_name = file_path.parent, file_path.name
service_item.title = file_name
if file_path.exists():
@@ -329,7 +327,7 @@
service_item.processor = self.display_type_combo_box.currentText()
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
for bitem in items:
- file_path = str_to_path(bitem.data(QtCore.Qt.UserRole))
+ file_path = bitem.data(QtCore.Qt.UserRole)
path, file_name = file_path.parent, file_path.name
service_item.title = file_name
if file_path.exists():
=== modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py'
--- openlp/plugins/songs/lib/importers/presentationmanager.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/presentationmanager.py 2019-05-04 18:26:39 +0000
@@ -48,7 +48,7 @@
tree = etree.parse(str(file_path), parser=etree.XMLParser(recover=True))
except etree.XMLSyntaxError:
# Try to detect encoding and use it
- encoding = get_file_encoding(file_path)['encoding']
+ encoding = get_file_encoding(file_path)
# Open file with detected encoding and remove encoding declaration
text = file_path.read_text(encoding=encoding)
text = re.sub(r'.+\?>\n', '', text)
=== modified file 'openlp/plugins/songs/lib/importers/songbeamer.py'
--- openlp/plugins/songs/lib/importers/songbeamer.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/songbeamer.py 2019-05-04 18:26:39 +0000
@@ -124,7 +124,7 @@
self.chord_table = None
if file_path.is_file():
# Detect the encoding
- self.input_file_encoding = get_file_encoding(file_path)['encoding']
+ self.input_file_encoding = get_file_encoding(file_path)
# The encoding should only be ANSI (cp1252), UTF-8, Unicode, Big-Endian-Unicode.
# So if it doesn't start with 'u' we default to cp1252. See:
# https://forum.songbeamer.com/viewtopic.php?p=419&sid=ca4814924e37c11e4438b7272a98b6f2
=== modified file 'openlp/plugins/songs/lib/importers/worshipassistant.py'
--- openlp/plugins/songs/lib/importers/worshipassistant.py 2019-04-13 13:00:22 +0000
+++ openlp/plugins/songs/lib/importers/worshipassistant.py 2019-05-04 18:26:39 +0000
@@ -82,7 +82,7 @@
Receive a CSV file to import.
"""
# Get encoding
- encoding = get_file_encoding(self.import_source)['encoding']
+ encoding = get_file_encoding(self.import_source)
with self.import_source.open('r', encoding=encoding) as songs_file:
songs_reader = csv.DictReader(songs_file, escapechar='\\')
try:
=== modified file 'tests/functional/openlp_core/common/test_common.py'
--- tests/functional/openlp_core/common/test_common.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/common/test_common.py 2019-05-04 18:26:39 +0000
@@ -88,7 +88,7 @@
extension_loader('glob')
# THEN: The `ImportError` should be caught and logged
- assert mocked_logger.warning.called
+ assert mocked_logger.exception.called
def test_extension_loader_os_error(self):
"""
@@ -106,7 +106,7 @@
extension_loader('glob')
# THEN: The `OSError` should be caught and logged
- assert mocked_logger.warning.called
+ assert mocked_logger.exception.called
def test_de_hump_conversion(self):
"""
=== modified file 'tests/functional/openlp_core/common/test_init.py'
--- tests/functional/openlp_core/common/test_init.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/common/test_init.py 2019-05-04 18:26:39 +0000
@@ -322,7 +322,7 @@
mocked_open.assert_called_once_with('rb')
assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256)]
mocked_universal_detector_inst.close.assert_called_once_with()
- assert result == encoding_result
+ assert result == 'UTF-8'
def test_get_file_encoding_eof(self):
"""
@@ -344,7 +344,7 @@
mocked_open.assert_called_once_with('rb')
assert mocked_universal_detector_inst.feed.mock_calls == [call(b'data' * 256), call(b'data' * 4)]
mocked_universal_detector_inst.close.assert_called_once_with()
- assert result == encoding_result
+ assert result == 'UTF-8'
def test_get_file_encoding_oserror(self):
"""
@@ -367,4 +367,4 @@
mocked_log.exception.assert_called_once_with('Error detecting file encoding')
mocked_universal_detector_inst.feed.assert_not_called()
mocked_universal_detector_inst.close.assert_called_once_with()
- assert result == encoding_result
+ assert result == 'UTF-8'
=== modified file 'tests/functional/openlp_core/test_app.py'
--- tests/functional/openlp_core/test_app.py 2019-05-01 19:22:01 +0000
+++ tests/functional/openlp_core/test_app.py 2019-05-04 18:26:39 +0000
@@ -138,7 +138,7 @@
assert args.loglevel == 'warning', 'The log level should be set to warning'
assert args.no_error_form is False, 'The no_error_form should be set to False'
assert args.portable is False, 'The portable flag should be set to false'
- assert args.rargs == 'dummy_temp', 'The service file should not be blank'
+ assert args.rargs == ['dummy_temp'], 'The service file should not be blank'
def test_parse_options_file_and_debug():
@@ -155,7 +155,7 @@
assert args.loglevel == ' debug', 'The log level should be set to debug'
assert args.no_error_form is False, 'The no_error_form should be set to False'
assert args.portable is False, 'The portable flag should be set to false'
- assert args.rargs == 'dummy_temp', 'The service file should not be blank'
+ assert args.rargs == ['dummy_temp'], 'The service file should not be blank'
@skip('Figure out why this is causing a segfault')
=== modified file 'tests/functional/openlp_core/test_server.py'
--- tests/functional/openlp_core/test_server.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/test_server.py 2019-05-04 18:26:39 +0000
@@ -22,6 +22,7 @@
from unittest import TestCase
from unittest.mock import MagicMock, patch
+from openlp.core.common.path import Path
from openlp.core.common.registry import Registry
from openlp.core.server import Server
from tests.helpers.testmixin import TestMixin
@@ -83,8 +84,8 @@
self.server._on_ready_read()
# THEN: the service will be loaded
- assert service_manager.on_load_service_clicked.call_count == 1
- service_manager.on_load_service_clicked.assert_called_once_with(file_name)
+ assert service_manager.load_service.call_count == 1
+ service_manager.load_service.assert_called_once_with(Path(file_name))
@patch("PyQt5.QtCore.QTextStream")
def test_post_to_server(self, mocked_stream):
=== modified file 'tests/functional/openlp_core/ui/test_mainwindow.py'
--- tests/functional/openlp_core/ui/test_mainwindow.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/ui/test_mainwindow.py 2019-05-04 18:26:39 +0000
@@ -96,7 +96,7 @@
# WHEN the argument is processed
with patch.object(self.main_window.service_manager, 'load_file') as mocked_load_file:
- self.main_window.open_cmd_line_files(service)
+ self.main_window.open_cmd_line_files([service])
# THEN the service from the arguments is loaded
mocked_load_file.assert_called_with(Path(service))
@@ -108,7 +108,6 @@
"""
# GIVEN a non service file as an argument to openlp
service = 'run_openlp.py'
- self.main_window.arguments = service
# WHEN the argument is processed
self.main_window.open_cmd_line_files(service)
=== modified file 'tests/functional/openlp_core/ui/test_thememanager.py'
--- tests/functional/openlp_core/ui/test_thememanager.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_core/ui/test_thememanager.py 2019-05-04 18:26:39 +0000
@@ -143,7 +143,7 @@
mocked_theme.export_theme.return_value = "{}"
# WHEN: Calling _write_theme with a theme with a name with special characters in it
- theme_manager._write_theme(mocked_theme, None, None)
+ theme_manager._write_theme(mocked_theme)
# THEN: It should have been created
assert os.path.exists(os.path.join(self.temp_folder, 'theme 愛 name', 'theme 愛 name.json')) is True, \
@@ -224,7 +224,7 @@
theme_manager = ThemeManager(None)
# WHEN: unzip_theme is called
- theme_manager.unzip_theme('theme.file', 'folder')
+ theme_manager.unzip_theme(Path('theme.file'), Path('folder'))
# THEN: The critical_error_message_box should have been called
assert mocked_critical_error_message_box.call_count == 1, 'Should have been called once'
=== modified file 'tests/functional/openlp_plugins/bibles/test_csvimport.py'
--- tests/functional/openlp_plugins/bibles/test_csvimport.py 2019-04-13 13:00:22 +0000
+++ tests/functional/openlp_plugins/bibles/test_csvimport.py 2019-05-04 18:26:39 +0000
@@ -136,8 +136,7 @@
mocked_enter_file = MagicMock()
mocked_csv_file.open.return_value.__enter__.return_value = mocked_enter_file
- with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding',
- return_value={'encoding': 'utf-8', 'confidence': 0.99}), \
+ with patch('openlp.plugins.bibles.lib.importers.csvbible.get_file_encoding', return_value='utf-8'), \
patch('openlp.plugins.bibles.lib.importers.csvbible.csv.reader',
return_value=iter(test_data)) as mocked_reader:
References