From bf9420a781ef65f972b8b1a88654f75556a36a50 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Wed, 30 Dec 2015 16:03:35 +0100 Subject: [PATCH 01/22] Update forms to remove the help button in the statusbar Fixes: https://launchpad.net/bugs/1490184 --- openlp/core/ui/aboutform.py | 5 +++-- openlp/core/ui/exceptionform.py | 3 ++- openlp/core/ui/filerenameform.py | 5 +++-- openlp/core/ui/firsttimelanguageform.py | 5 +++-- openlp/core/ui/formattingtagform.py | 5 +++-- openlp/core/ui/pluginform.py | 5 +++-- openlp/core/ui/printserviceform.py | 3 ++- openlp/core/ui/projector/editform.py | 3 ++- openlp/core/ui/projector/sourceselectform.py | 6 ++++-- openlp/core/ui/serviceitemeditform.py | 5 +++-- openlp/core/ui/servicenoteform.py | 5 +++-- openlp/core/ui/settingsform.py | 3 ++- openlp/core/ui/shortcutlistform.py | 3 ++- openlp/core/ui/starttimeform.py | 5 +++-- openlp/plugins/alerts/forms/alertform.py | 3 ++- openlp/plugins/bibles/forms/booknameform.py | 3 ++- openlp/plugins/bibles/forms/editbibleform.py | 5 +++-- openlp/plugins/bibles/forms/languageform.py | 4 +++- openlp/plugins/custom/forms/editcustomform.py | 5 +++-- openlp/plugins/custom/forms/editcustomslideform.py | 5 +++-- openlp/plugins/images/forms/addgroupform.py | 5 +++-- openlp/plugins/images/forms/choosegroupform.py | 5 +++-- openlp/plugins/media/forms/mediaclipselectorform.py | 3 ++- openlp/plugins/songs/forms/authorsform.py | 5 +++-- openlp/plugins/songs/forms/editsongform.py | 3 ++- openlp/plugins/songs/forms/editverseform.py | 5 +++-- openlp/plugins/songs/forms/mediafilesform.py | 3 ++- openlp/plugins/songs/forms/songbookform.py | 5 +++-- openlp/plugins/songs/forms/songmaintenanceform.py | 3 ++- openlp/plugins/songs/forms/songselectform.py | 3 ++- openlp/plugins/songs/forms/topicsform.py | 5 +++-- openlp/plugins/songusage/forms/songusagedeleteform.py | 5 +++-- openlp/plugins/songusage/forms/songusagedetailform.py | 5 +++-- 33 files changed, 88 insertions(+), 53 deletions(-) diff --git a/openlp/core/ui/aboutform.py b/openlp/core/ui/aboutform.py index 67e0a971f..018ef84bc 100644 --- a/openlp/core/ui/aboutform.py +++ b/openlp/core/ui/aboutform.py @@ -24,7 +24,7 @@ The About dialog. """ import webbrowser -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import translate from openlp.core.utils import get_application_version @@ -40,7 +40,8 @@ class AboutForm(QtWidgets.QDialog, UiAboutDialog): """ Do some initialisation stuff """ - super(AboutForm, self).__init__(parent) + super(AboutForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self._setup() def _setup(self): diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index cc6362290..0624f492d 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -89,7 +89,8 @@ class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties): """ Constructor. """ - super(ExceptionForm, self).__init__() + super(ExceptionForm, self).__init__(None, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.settings_section = 'crashreport' self.report_text = '**OpenLP Bug Report**\n' \ diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 7d84a97d2..9da573f04 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -23,7 +23,7 @@ The file rename dialog. """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from .filerenamedialog import Ui_FileRenameDialog @@ -38,7 +38,8 @@ class FileRenameForm(QtWidgets.QDialog, Ui_FileRenameDialog, RegistryProperties) """ Constructor """ - super(FileRenameForm, self).__init__(Registry().get('main_window')) + super(FileRenameForm, self).__init__(Registry().get('main_window'), + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self._setup() def _setup(self): diff --git a/openlp/core/ui/firsttimelanguageform.py b/openlp/core/ui/firsttimelanguageform.py index b1bd7e7f4..329cae398 100644 --- a/openlp/core/ui/firsttimelanguageform.py +++ b/openlp/core/ui/firsttimelanguageform.py @@ -22,7 +22,7 @@ """ The language selection dialog. """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.lib.ui import create_action from openlp.core.utils import LanguageManager @@ -37,7 +37,8 @@ class FirstTimeLanguageForm(QtWidgets.QDialog, Ui_FirstTimeLanguageDialog): """ Constructor """ - super(FirstTimeLanguageForm, self).__init__(parent) + super(FirstTimeLanguageForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.qm_list = LanguageManager.get_qm_list() self.language_combo_box.addItem('Autodetect') diff --git a/openlp/core/ui/formattingtagform.py b/openlp/core/ui/formattingtagform.py index bd2a32978..7e48b2613 100644 --- a/openlp/core/ui/formattingtagform.py +++ b/openlp/core/ui/formattingtagform.py @@ -25,7 +25,7 @@ Custom tags can be defined and saved. The Custom Tag arrays are saved in a json Base Tags cannot be changed. """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib import FormattingTags @@ -51,7 +51,8 @@ class FormattingTagForm(QtWidgets.QDialog, Ui_FormattingTagDialog, FormattingTag """ Constructor """ - super(FormattingTagForm, self).__init__(parent) + super(FormattingTagForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self._setup() diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 4eacebdab..1a8bfcc35 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -24,7 +24,7 @@ The actual plugin view form """ import logging -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import RegistryProperties, translate from openlp.core.lib import PluginStatus @@ -41,7 +41,8 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ Constructor """ - super(PluginForm, self).__init__(parent) + super(PluginForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.active_plugin = None self.programatic_change = False self.setupUi(self) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index cfe0d883a..b62aac9a5 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -112,7 +112,8 @@ class PrintServiceForm(QtWidgets.QDialog, Ui_PrintServiceDialog, RegistryPropert """ Constructor """ - super(PrintServiceForm, self).__init__(Registry().get('main_window')) + super(PrintServiceForm, self).__init__(Registry().get('main_window'), + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.printer = QtPrintSupport.QPrinter() self.print_dialog = QtPrintSupport.QPrintDialog(self.printer, self) self.document = QtGui.QTextDocument() diff --git a/openlp/core/ui/projector/editform.py b/openlp/core/ui/projector/editform.py index df0c57b4c..b4447b605 100644 --- a/openlp/core/ui/projector/editform.py +++ b/openlp/core/ui/projector/editform.py @@ -144,7 +144,8 @@ class ProjectorEditForm(QDialog, Ui_ProjectorEditForm): editProjector = pyqtSignal(object) def __init__(self, parent=None, projectordb=None): - super(ProjectorEditForm, self).__init__(parent=parent) + super(ProjectorEditForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.projectordb = projectordb self.setupUi(self) self.button_box.accepted.connect(self.accept_me) diff --git a/openlp/core/ui/projector/sourceselectform.py b/openlp/core/ui/projector/sourceselectform.py index de0cbd2c8..c135d3422 100644 --- a/openlp/core/ui/projector/sourceselectform.py +++ b/openlp/core/ui/projector/sourceselectform.py @@ -236,7 +236,8 @@ class SourceSelectTabs(QDialog): :param projectordb: ProjectorDB session to use """ log.debug('Initializing SourceSelectTabs()') - super(SourceSelectTabs, self).__init__(parent) + super(SourceSelectTabs, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setMinimumWidth(350) self.projectordb = projectordb self.edit = edit @@ -385,7 +386,8 @@ class SourceSelectSingle(QDialog): """ log.debug('Initializing SourceSelectSingle()') self.projectordb = projectordb - super(SourceSelectSingle, self).__init__(parent) + super(SourceSelectSingle, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.edit = edit if self.edit: title = translate('OpenLP.SourceSelectForm', 'Edit Projector Source Text') diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index 3e8b140c1..cc705f1bb 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -22,7 +22,7 @@ """ The service item edit dialog """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties @@ -37,7 +37,8 @@ class ServiceItemEditForm(QtWidgets.QDialog, Ui_ServiceItemEditDialog, RegistryP """ Constructor """ - super(ServiceItemEditForm, self).__init__(Registry().get('main_window')) + super(ServiceItemEditForm, self).__init__(Registry().get('main_window'), + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.item_list = [] self.list_widget.currentRowChanged.connect(self.on_current_row_changed) diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 54a09ee25..1c9deb452 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -22,7 +22,7 @@ """ The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm` class. """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, RegistryProperties, translate from openlp.core.lib import SpellTextEdit @@ -37,7 +37,8 @@ class ServiceNoteForm(QtWidgets.QDialog, RegistryProperties): """ Constructor """ - super(ServiceNoteForm, self).__init__(Registry().get('main_window')) + super(ServiceNoteForm, self).__init__(Registry().get('main_window'), + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi() self.retranslateUi() diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 628cd68a8..fc1ec2470 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -46,7 +46,8 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties): """ Registry().register('settings_form', self) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up) - super(SettingsForm, self).__init__(parent) + super(SettingsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.processes = [] self.setupUi(self) self.setting_list_widget.currentRowChanged.connect(self.list_item_changed) diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 5af14cb80..40d72bb9a 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -44,7 +44,8 @@ class ShortcutListForm(QtWidgets.QDialog, Ui_ShortcutListDialog, RegistryPropert """ Constructor """ - super(ShortcutListForm, self).__init__(parent) + super(ShortcutListForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.changed_actions = {} self.action_list = ActionList.get_instance() diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index c37c4dacf..7e30e7a6a 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -22,7 +22,7 @@ """ The actual start time form. """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from .starttimedialog import Ui_StartTimeDialog @@ -38,7 +38,8 @@ class StartTimeForm(QtWidgets.QDialog, Ui_StartTimeDialog, RegistryProperties): """ Constructor """ - super(StartTimeForm, self).__init__(Registry().get('main_window')) + super(StartTimeForm, self).__init__(Registry().get('main_window'), + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self): diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 8656ef193..09de831fa 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -36,10 +36,11 @@ class AlertForm(QtWidgets.QDialog, Ui_AlertDialog): """ Initialise the alert form """ + super(AlertForm, self).__init__(Registry().get('main_window'), + QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) self.manager = plugin.manager self.plugin = plugin self.item_id = None - super(AlertForm, self).__init__(Registry().get('main_window')) self.setupUi(self) self.display_button.clicked.connect(self.on_display_clicked) self.display_close_button.clicked.connect(self.on_display_close_clicked) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 2fe79510b..fc27711b3 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -49,7 +49,8 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ Constructor """ - super(BookNameForm, self).__init__(parent) + super(BookNameForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.custom_signals() self.book_names = BibleStrings().BookNames diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 64399dc2d..9d8f7a228 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -24,7 +24,7 @@ import logging import os import re -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import RegistryProperties, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box @@ -45,7 +45,8 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties): """ Constructor """ - super(EditBibleForm, self).__init__(parent) + super(EditBibleForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.media_item = media_item self.book_names = BibleStrings().BookNames self.setupUi(self) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index f0e270a4a..ef255b5d5 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -26,6 +26,7 @@ Module implementing LanguageForm. import logging from PyQt5.QtWidgets import QDialog +from PyQt5 import QtCore from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box @@ -46,7 +47,8 @@ class LanguageForm(QDialog, Ui_LanguageDialog): """ Constructor """ - super(LanguageForm, self).__init__(parent) + super(LanguageForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, bible_name): diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 42dad7410..00997a3d9 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -22,7 +22,7 @@ import logging -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import Registry, translate from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box @@ -44,7 +44,8 @@ class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog): """ Constructor """ - super(EditCustomForm, self).__init__(parent) + super(EditCustomForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.manager = manager self.media_item = media_item self.setupUi(self) diff --git a/openlp/plugins/custom/forms/editcustomslideform.py b/openlp/plugins/custom/forms/editcustomslideform.py index fb4ba3535..e7d812c4a 100644 --- a/openlp/plugins/custom/forms/editcustomslideform.py +++ b/openlp/plugins/custom/forms/editcustomslideform.py @@ -22,7 +22,7 @@ import logging -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from .editcustomslidedialog import Ui_CustomSlideEditDialog @@ -39,7 +39,8 @@ class EditCustomSlideForm(QtWidgets.QDialog, Ui_CustomSlideEditDialog): """ Constructor """ - super(EditCustomSlideForm, self).__init__(parent) + super(EditCustomSlideForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) # Connecting signals and slots self.insert_button.clicked.connect(self.on_insert_button_clicked) diff --git a/openlp/plugins/images/forms/addgroupform.py b/openlp/plugins/images/forms/addgroupform.py index 6dc5c51d3..9db89ada9 100644 --- a/openlp/plugins/images/forms/addgroupform.py +++ b/openlp/plugins/images/forms/addgroupform.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import translate from openlp.core.lib.ui import critical_error_message_box @@ -35,7 +35,8 @@ class AddGroupForm(QtWidgets.QDialog, Ui_AddGroupDialog): """ Constructor """ - super(AddGroupForm, self).__init__(parent) + super(AddGroupForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, clear=True, show_top_level_group=False, selected_group=None): diff --git a/openlp/plugins/images/forms/choosegroupform.py b/openlp/plugins/images/forms/choosegroupform.py index 6ab560bf4..864d84ba6 100644 --- a/openlp/plugins/images/forms/choosegroupform.py +++ b/openlp/plugins/images/forms/choosegroupform.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.plugins.images.forms.choosegroupdialog import Ui_ChooseGroupDialog @@ -33,7 +33,8 @@ class ChooseGroupForm(QtWidgets.QDialog, Ui_ChooseGroupDialog): """ Constructor """ - super(ChooseGroupForm, self).__init__(parent) + super(ChooseGroupForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, selected_group=None): diff --git a/openlp/plugins/media/forms/mediaclipselectorform.py b/openlp/plugins/media/forms/mediaclipselectorform.py index 94e58926d..3cf9c8cc3 100644 --- a/openlp/plugins/media/forms/mediaclipselectorform.py +++ b/openlp/plugins/media/forms/mediaclipselectorform.py @@ -52,7 +52,8 @@ class MediaClipSelectorForm(QtWidgets.QDialog, Ui_MediaClipSelector, RegistryPro """ Constructor """ - super(MediaClipSelectorForm, self).__init__(parent) + super(MediaClipSelectorForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.vlc_instance = None self.vlc_media_player = None self.vlc_media = None diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 3f0ef62cc..ed28679c9 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box @@ -35,7 +35,8 @@ class AuthorsForm(QtWidgets.QDialog, Ui_AuthorsDialog): """ Set up the screen and common data """ - super(AuthorsForm, self).__init__(parent) + super(AuthorsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.auto_display_name = False self.first_name_edit.textEdited.connect(self.on_first_name_edited) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 4158d8210..58ee8e02f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -55,7 +55,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): """ Constructor """ - super(EditSongForm, self).__init__(parent) + super(EditSongForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.media_item = media_item self.song = None # can this be automated? diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 83e667660..31e694ee4 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -23,7 +23,7 @@ import re import logging -from PyQt5 import QtGui, QtWidgets +from PyQt5 import QtCore, QtGui, QtWidgets from openlp.plugins.songs.lib import VerseType from .editversedialog import Ui_EditVerseDialog @@ -41,7 +41,8 @@ class EditVerseForm(QtWidgets.QDialog, Ui_EditVerseDialog): """ Constructor """ - super(EditVerseForm, self).__init__(parent) + super(EditVerseForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.has_single_verse = False self.insert_button.clicked.connect(self.on_insert_button_clicked) diff --git a/openlp/plugins/songs/forms/mediafilesform.py b/openlp/plugins/songs/forms/mediafilesform.py index 9ff328f9e..68b245d7b 100644 --- a/openlp/plugins/songs/forms/mediafilesform.py +++ b/openlp/plugins/songs/forms/mediafilesform.py @@ -37,7 +37,8 @@ class MediaFilesForm(QtWidgets.QDialog, Ui_MediaFilesDialog): log.info('%s MediaFilesForm loaded', __name__) def __init__(self, parent): - super(MediaFilesForm, self).__init__() + super(MediaFilesForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) def populate_files(self, files): diff --git a/openlp/plugins/songs/forms/songbookform.py b/openlp/plugins/songs/forms/songbookform.py index 7207a3859..755947f95 100644 --- a/openlp/plugins/songs/forms/songbookform.py +++ b/openlp/plugins/songs/forms/songbookform.py @@ -23,7 +23,7 @@ This module contains the song book form """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box @@ -38,7 +38,8 @@ class SongBookForm(QtWidgets.QDialog, Ui_SongBookDialog): """ Constructor """ - super(SongBookForm, self).__init__(parent) + super(SongBookForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, clear=True): diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 1f05ae3a5..cff25237a 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -44,7 +44,8 @@ class SongMaintenanceForm(QtWidgets.QDialog, Ui_SongMaintenanceDialog, RegistryP """ Constructor """ - super(SongMaintenanceForm, self).__init__(parent) + super(SongMaintenanceForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.manager = manager self.author_form = AuthorsForm(self) diff --git a/openlp/plugins/songs/forms/songselectform.py b/openlp/plugins/songs/forms/songselectform.py index b8d410c43..b69d9061f 100755 --- a/openlp/plugins/songs/forms/songselectform.py +++ b/openlp/plugins/songs/forms/songselectform.py @@ -81,7 +81,8 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog): """ def __init__(self, parent=None, plugin=None, db_manager=None): - QtWidgets.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.plugin = plugin self.db_manager = db_manager self.setup_ui(self) diff --git a/openlp/plugins/songs/forms/topicsform.py b/openlp/plugins/songs/forms/topicsform.py index 35fdafdc3..da3ca1da4 100644 --- a/openlp/plugins/songs/forms/topicsform.py +++ b/openlp/plugins/songs/forms/topicsform.py @@ -23,7 +23,7 @@ This module contains the topic edit form. """ -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box @@ -38,7 +38,8 @@ class TopicsForm(QtWidgets.QDialog, Ui_TopicsDialog): """ Constructor """ - super(TopicsForm, self).__init__(parent) + super(TopicsForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) def exec(self, clear=True): diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index 173f371a8..a7a8df408 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -20,7 +20,7 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from openlp.core.common import RegistryProperties, translate from openlp.plugins.songusage.lib.db import SongUsageItem @@ -36,7 +36,8 @@ class SongUsageDeleteForm(QtWidgets.QDialog, Ui_SongUsageDeleteDialog, RegistryP Constructor """ self.manager = manager - super(SongUsageDeleteForm, self).__init__(parent) + super(SongUsageDeleteForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.setupUi(self) self.button_box.clicked.connect(self.on_button_box_clicked) diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 680b258e0..4b20a603b 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -23,7 +23,7 @@ import logging import os -from PyQt5 import QtWidgets +from PyQt5 import QtCore, QtWidgets from sqlalchemy.sql import and_ from openlp.core.common import RegistryProperties, Settings, check_directory_exists, translate @@ -44,7 +44,8 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP """ Initialise the form """ - super(SongUsageDetailForm, self).__init__(parent) + super(SongUsageDetailForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint + | QtCore.Qt.WindowTitleHint) self.plugin = plugin self.setupUi(self) From 990a8a95022838032dafc0070a58f52f8b105709 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Wed, 30 Dec 2015 22:36:37 +0100 Subject: [PATCH 02/22] Add tests for the SongFormat class --- .../openlp_plugins/songs/test_songformat.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/functional/openlp_plugins/songs/test_songformat.py diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py new file mode 100644 index 000000000..bcfbfe2a5 --- /dev/null +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2015 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; version 2 of the License. # +# # +# 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, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +This module contains tests for the SongFormat class +""" +from unittest import TestCase + +from openlp.plugins.songs.lib.importer import SongFormat + + +class TestSongFormat(TestCase): + + def test_get_format_list(self): + self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__)) + + def test_get_attributed_no_attributes(self): + for song_format in SongFormat.get_format_list(): + self.assertEquals(SongFormat.__attributes__[song_format], SongFormat.get(song_format)) + + def test_get_attributed_single_attribute(self): + for song_format in SongFormat.get_format_list(): + for attribute in SongFormat.get(song_format).keys(): + self.assertEquals(SongFormat.get(song_format, attribute), + SongFormat.get(song_format)[attribute]) + for attribute in SongFormat.__defaults__.keys(): + if attribute not in SongFormat.get(song_format).keys(): + self.assertEquals(SongFormat.get(song_format, attribute), + SongFormat.__defaults__[attribute]) + + def test_get_attributed_multiple_attributes(self): + for song_format in SongFormat.get_format_list(): + self.assertEquals(2, len(SongFormat.get(song_format, 'canDisable', 'availability'))) + From c7563a5a6409a90634fafd555e2b3be99d866085 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 00:37:22 +0100 Subject: [PATCH 03/22] Add documentation to tests --- .bzrignore | 2 ++ .../openlp_plugins/songs/test_songformat.py | 31 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.bzrignore b/.bzrignore index 272c37e88..2e2e4891f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -43,3 +43,5 @@ __pycache__ .coverage cover *.kdev4 +./.coveragerc +./coverage diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py index bcfbfe2a5..be4216ef5 100644 --- a/tests/functional/openlp_plugins/songs/test_songformat.py +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -30,23 +30,40 @@ from openlp.plugins.songs.lib.importer import SongFormat class TestSongFormat(TestCase): def test_get_format_list(self): - self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__)) + # GIVEN: The SongFormat class + # WHEN: Retrieving the format list + # THEN: All SongFormats should be returned + self.assertEquals(len(SongFormat.get_format_list()), len(SongFormat.__attributes__), + "The returned SongFormats don't match the stored ones") def test_get_attributed_no_attributes(self): + # GIVEN: A SongFormat + # WHEN: Retrieving all attributes of a SongFormat for song_format in SongFormat.get_format_list(): - self.assertEquals(SongFormat.__attributes__[song_format], SongFormat.get(song_format)) + # THEN: All attributes associated with the SongFormat should be returned + self.assertEquals(SongFormat.get(song_format), SongFormat.__attributes__[song_format], + "The returned attributes don't match the stored ones") def test_get_attributed_single_attribute(self): + # GIVEN: A SongFormat for song_format in SongFormat.get_format_list(): + # WHEN: Retrieving an attribute that overrides the default values for attribute in SongFormat.get(song_format).keys(): - self.assertEquals(SongFormat.get(song_format, attribute), - SongFormat.get(song_format)[attribute]) + # THEN: Return the attribute + self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.get(song_format)[attribute], + "The returned attribute doesn't match the stored one") + # WHEN: Retrieving an attribute that was not overridden for attribute in SongFormat.__defaults__.keys(): if attribute not in SongFormat.get(song_format).keys(): - self.assertEquals(SongFormat.get(song_format, attribute), - SongFormat.__defaults__[attribute]) + # THEN: Return the default value + self.assertEquals(SongFormat.get(song_format, attribute), SongFormat.__defaults__[attribute], + "The returned attribute does not match the default values stored") def test_get_attributed_multiple_attributes(self): + # GIVEN: A SongFormat + # WHEN: Retrieving multiple attributes at the same time for song_format in SongFormat.get_format_list(): - self.assertEquals(2, len(SongFormat.get(song_format, 'canDisable', 'availability'))) + # THEN: Return all attributes that were specified + self.assertEquals(len(SongFormat.get(song_format, 'canDisable', 'availability')), 2, + "Did not return the correct number of attributes when retrieving multiple attributes at once") From c47d1bdca4c74db1df2fa9b368e9547dbcc3e801 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 5 Jan 2016 16:32:49 +0100 Subject: [PATCH 04/22] Select text in search field when it gains focus Fixes: https://launchpad.net/bugs/1530340 --- openlp/plugins/bibles/lib/mediaitem.py | 1 + openlp/plugins/custom/lib/mediaitem.py | 1 + openlp/plugins/songs/lib/mediaitem.py | 1 + 3 files changed, 3 insertions(+) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 3934ca53c..94937e61b 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -254,6 +254,7 @@ class BibleMediaItem(MediaManagerItem): def on_focus(self): if self.quickTab.isVisible(): self.quick_search_edit.setFocus() + self.quick_search_edit.selectAll() else: self.advanced_book_combo_box.setFocus() diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 812274263..c7f3167ea 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -208,6 +208,7 @@ class CustomMediaItem(MediaManagerItem): Set the focus """ self.search_text_edit.setFocus() + self.search_text_edit.selectAll() def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False, context=ServiceItemContext.Service): diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 4f23bbfd1..0c70d6ad0 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -112,6 +112,7 @@ class SongMediaItem(MediaManagerItem): def on_focus(self): self.search_text_edit.setFocus() + self.search_text_edit.selectAll() def config_update(self): """ From 0cd2bbff36c66e769e8c2625bf06b8ed90c102eb Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 5 Jan 2016 16:42:07 +0100 Subject: [PATCH 05/22] Convert lowercase verse order to uppercase automatically Fixes: https://launchpad.net/bugs/1530354 --- openlp/plugins/songs/forms/editsongform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index d598e848b..7bf6bbc48 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -803,6 +803,8 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): :param text: The text of the verse order edit (ignored). """ + # First make sure that all letters entered in the verse order field are uppercase + self.verse_order_edit.setText(text.upper()) # Extract all verses which were used in the order. verses_in_order = self._extract_verse_order(self.verse_order_edit.text()) # Find the verses which were not used in the order. From 860f596dde1901eb4fddfb9dbc943e42ef846d2d Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 5 Jan 2016 17:10:16 +0100 Subject: [PATCH 06/22] Only trigger this method by user input Else we will have infinite loop by using setText in that method --- openlp/plugins/songs/forms/editsongform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 7bf6bbc48..e79fc633f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -76,7 +76,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): self.verse_edit_all_button.clicked.connect(self.on_verse_edit_all_button_clicked) self.verse_delete_button.clicked.connect(self.on_verse_delete_button_clicked) self.verse_list_widget.itemClicked.connect(self.on_verse_list_view_clicked) - self.verse_order_edit.textChanged.connect(self.on_verse_order_text_changed) + self.verse_order_edit.textEdited.connect(self.on_verse_order_text_changed) self.theme_add_button.clicked.connect(self.theme_manager.on_add_theme) self.maintenance_button.clicked.connect(self.on_maintenance_button_clicked) self.from_file_button.clicked.connect(self.on_audio_add_from_file_button_clicked) From 75b885961e8545cd20b9bf181f7427d60055cd99 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 5 Jan 2016 17:11:30 +0100 Subject: [PATCH 07/22] Add test for converting verse order to uppercase --- .../songs/forms/test_editsongform.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py index d540a90c5..bb26533ee 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py @@ -142,3 +142,18 @@ class TestEditSongForm(TestCase, TestMixin): 'CCLI label should not be "{}"'.format(UiStrings().CCLINumberLabel)) self.assertEquals(form.ccli_label.text(), UiStrings().CCLISongNumberLabel, 'CCLI label text should be "{}"'.format(UiStrings().CCLISongNumberLabel)) + + def verse_order_lowercase_test(self): + """ + Test that entering a verse order in lowercase automatically converts to uppercase + """ + # GIVEN; Mocked methods + form = self.form + + # WHEN: We enter a verse order in lowercase + form.verse_order_edit.setText('v1 v2 c1 v3 c1 v4 c1') + # Need to manually trigger this method as it is only triggered by manual input + form.on_verse_order_text_changed(form.verse_order_edit.text()) + + # THEN: The verse order should be converted to uppercase + self.assertEqual(form.verse_order_edit.text(), 'V1 V2 C1 V3 C1 V4 C1') From 3975901e11cc892e929081536ee2ec9edbc157dc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 5 Jan 2016 18:19:40 +0000 Subject: [PATCH 08/22] Fix search breakage --- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 2 +- openlp/plugins/remotes/html/openlp.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 3934ca53c..57a789ee2 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -960,7 +960,7 @@ class BibleMediaItem(MediaManagerItem): search_results = self.plugin.manager.get_verses(bible, string, False, showError) if search_results: verse_text = ' '.join([verse.text for verse in search_results]) - return [[string, verse_text]] + return [[string, verse_text, ""]] return [] def create_item_from_id(self, item_id): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 248da94ea..85c5ace72 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -701,7 +701,7 @@ class ImageMediaItem(MediaManagerItem): results = [] for file_object in files: filename = os.path.split(str(file_object.filename))[1] - results.append([file_object.filename, filename]) + results.append([file_object.filename, filename, ""]) return results def create_item_from_id(self, item_id): diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index a5be8b25c..73a84649b 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -272,7 +272,7 @@ window.OpenLP = { value[0] = OpenLP.escapeString(value[0]) } var txt = ""; - if (value[2].length > 0) { + if (value.length > 2 && value[2].length > 0) { txt = value[1] + " ( " + value[2] + " )"; } else { txt = value[1]; From 2bbdf51aca27b6970e4cf68db9aca2ad9cde6455 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 5 Jan 2016 18:20:47 +0000 Subject: [PATCH 09/22] remove extra string --- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/images/lib/mediaitem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 57a789ee2..3934ca53c 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -960,7 +960,7 @@ class BibleMediaItem(MediaManagerItem): search_results = self.plugin.manager.get_verses(bible, string, False, showError) if search_results: verse_text = ' '.join([verse.text for verse in search_results]) - return [[string, verse_text, ""]] + return [[string, verse_text]] return [] def create_item_from_id(self, item_id): diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 85c5ace72..248da94ea 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -701,7 +701,7 @@ class ImageMediaItem(MediaManagerItem): results = [] for file_object in files: filename = os.path.split(str(file_object.filename))[1] - results.append([file_object.filename, filename, ""]) + results.append([file_object.filename, filename]) return results def create_item_from_id(self, item_id): From 8df7c3a9ead53723146cd2be0e213809567cb4a2 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 5 Jan 2016 19:32:12 +0000 Subject: [PATCH 10/22] add tests --- openlp/plugins/remotes/html/openlp.js | 2 +- .../openlp_plugins/songs/test_mediaitem.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/remotes/html/openlp.js b/openlp/plugins/remotes/html/openlp.js index 73a84649b..128c78cb6 100644 --- a/openlp/plugins/remotes/html/openlp.js +++ b/openlp/plugins/remotes/html/openlp.js @@ -272,7 +272,7 @@ window.OpenLP = { value[0] = OpenLP.escapeString(value[0]) } var txt = ""; - if (value.length > 2 && value[2].length > 0) { + if (value.length > 2) { txt = value[1] + " ( " + value[2] + " )"; } else { txt = value[1]; diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index a19f7d704..bc6e56af5 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -257,3 +257,22 @@ class TestMediaItem(TestCase, TestMixin): # THEN: They should not match self.assertFalse(result, "Authors should not match") + + def build_remote_search_test(self): + """ + Test results for the remote search api + """ + # GIVEN: A Song and a search a JSON array should be returned. + mock_song = MagicMock() + mock_song.id = 123 + mock_song.title = 'My Song' + mock_song.search_title = 'My Song' + mock_song.alternate_title = 'My alternative' + self.media_item.search_entire = MagicMock() + self.media_item.search_entire.return_value = [mock_song] + + # WHEN: I process a search + search_results = self.media_item.search('My Song', False) + + # THEN: The correct formatted results are returned + self.assertEqual(search_results, [[123, 'My Song', 'My alternative']]) From 46301b63f403ac8657c26b05854e220d1906f80b Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Tue, 5 Jan 2016 22:35:35 +0100 Subject: [PATCH 11/22] Add docstrings to tests --- .../openlp_plugins/songs/test_songformat.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/functional/openlp_plugins/songs/test_songformat.py b/tests/functional/openlp_plugins/songs/test_songformat.py index be4216ef5..eab9760b8 100644 --- a/tests/functional/openlp_plugins/songs/test_songformat.py +++ b/tests/functional/openlp_plugins/songs/test_songformat.py @@ -28,8 +28,14 @@ from openlp.plugins.songs.lib.importer import SongFormat class TestSongFormat(TestCase): + """ + Test the functions in the :class:`SongFormat` class. + """ def test_get_format_list(self): + """ + Test that get_format_list() returns all available formats + """ # GIVEN: The SongFormat class # WHEN: Retrieving the format list # THEN: All SongFormats should be returned @@ -37,6 +43,9 @@ class TestSongFormat(TestCase): "The returned SongFormats don't match the stored ones") def test_get_attributed_no_attributes(self): + """ + Test that SongFormat.get(song_format) returns all attributes associated with the given song_format + """ # GIVEN: A SongFormat # WHEN: Retrieving all attributes of a SongFormat for song_format in SongFormat.get_format_list(): @@ -45,6 +54,9 @@ class TestSongFormat(TestCase): "The returned attributes don't match the stored ones") def test_get_attributed_single_attribute(self): + """ + Test that SongFormat.get(song_format, attribute) returns only one -and the correct- attribute + """ # GIVEN: A SongFormat for song_format in SongFormat.get_format_list(): # WHEN: Retrieving an attribute that overrides the default values @@ -60,6 +72,9 @@ class TestSongFormat(TestCase): "The returned attribute does not match the default values stored") def test_get_attributed_multiple_attributes(self): + """ + Test that multiple attributes can be retrieved for a song_format + """ # GIVEN: A SongFormat # WHEN: Retrieving multiple attributes at the same time for song_format in SongFormat.get_format_list(): From 584a0fda0dae2604912bcfcb91eafedb46cae30f Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Tue, 5 Jan 2016 23:58:04 +0100 Subject: [PATCH 12/22] Fix the deletion of songs This was left out when migrating to Qt 5 --- openlp/plugins/songs/lib/mediaitem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 4f23bbfd1..35ca9861c 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -363,8 +363,8 @@ class SongMediaItem(MediaManagerItem): items = self.list_view.selectedIndexes() if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, - translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '', - QtCore.QCoreApplication.CodecForTr, len(items)), + translate('SongsPlugin.MediaItem', + 'Are you sure you want to delete the "%d" selected song(s)?') % len(items), QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: return From 11876436a139e5bf59a3fcc7ea9d93d219227b9d Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Wed, 6 Jan 2016 00:58:31 +0100 Subject: [PATCH 13/22] Fix deletion of custom slides --- openlp/plugins/custom/lib/mediaitem.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 812274263..25970a91d 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -190,8 +190,7 @@ class CustomMediaItem(MediaManagerItem): if QtWidgets.QMessageBox.question( self, UiStrings().ConfirmDelete, translate('CustomPlugin.MediaItem', - 'Are you sure you want to delete the %n selected custom slide(s)?', - '', QtCore.QCoreApplication.CodecForTr, len(items)), + 'Are you sure you want to delete the "%d" selected custom slide(s)?') %len(items), QtWidgets.QMessageBox.StandardButtons( QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No), QtWidgets.QMessageBox.Yes) == QtWidgets.QMessageBox.No: From 51eefc84d91442a0663db81ea88e368335863384 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 6 Jan 2016 22:00:51 +0200 Subject: [PATCH 14/22] Fix OS X test which wasn't being skipped on non-OS X platforms --- tests/functional/openlp_core_ui/test_maindisplay.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/functional/openlp_core_ui/test_maindisplay.py b/tests/functional/openlp_core_ui/test_maindisplay.py index 6e187d44e..1f4649dbc 100644 --- a/tests/functional/openlp_core_ui/test_maindisplay.py +++ b/tests/functional/openlp_core_ui/test_maindisplay.py @@ -22,7 +22,7 @@ """ Package to test the openlp.core.ui.slidecontroller package. """ -from unittest import TestCase +from unittest import TestCase, skipUnless from PyQt5 import QtCore @@ -141,13 +141,14 @@ class TestMainDisplay(TestCase, TestMixin): mocked_songs_plugin.refresh_css.assert_called_with(main_display.frame) mocked_bibles_plugin.refresh_css.assert_called_with(main_display.frame) - @patch('openlp.core.ui.maindisplay.is_macosx') + @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.') def macosx_display_window_flags_state_test(self, is_macosx): """ Test that on Mac OS X we set the proper window flags """ + if not is_macosx(): + self.skipTest('Can only run test on Mac OS X due to pyobjc dependency.') # GIVEN: A new SlideController instance on Mac OS X. - is_macosx.return_value = True self.screens.set_current_display(0) display = MagicMock() @@ -159,12 +160,11 @@ class TestMainDisplay(TestCase, TestMixin): main_display.windowFlags(), 'The window flags should be Qt.Window, and Qt.FramelessWindowHint.') + @skipUnless(is_macosx(), 'Can only run test on Mac OS X due to pyobjc dependency.') def macosx_display_test(self): """ Test display on Mac OS X """ - if not is_macosx(): - self.skipTest('Can only run test on Mac OS X due to pyobjc dependency.') # GIVEN: A new SlideController instance on Mac OS X. self.screens.set_current_display(0) display = MagicMock() From b1febaa452ffdbc95792efd8f9c0ffa48b91f4c5 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Wed, 6 Jan 2016 22:02:39 +0200 Subject: [PATCH 15/22] Try to make sense of what the projector stuff is supposed to be doing. Found that internally the normal init_url was being called, which was wrong (i.e. it was being called twice, once from a plugin perspective, and then again from the projector perspective). Also, self.db_url was not being applied. --- openlp/core/lib/db.py | 28 ++++++++--------- openlp/core/lib/projector/db.py | 30 +++++++++---------- .../openlp_core_lib/test_projectordb.py | 29 +++++++++--------- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index b49539080..6eb67b5df 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -55,7 +55,7 @@ def init_db(url, auto_flush=True, auto_commit=False, base=None): metadata = MetaData(bind=engine) else: base.metadata.bind = engine - metadata = None + metadata = base.metadata session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine)) return session, metadata @@ -227,12 +227,9 @@ class Manager(object): """ self.is_dirty = False self.session = None - # See if we're using declarative_base with a pre-existing session. - log.debug('Manager: Testing for pre-existing session') - if session is not None: - log.debug('Manager: Using existing session') - else: - log.debug('Manager: Creating new session') + self.db_url = None + if db_file_name: + log.debug('Manager: Creating new DB url') self.db_url = init_url(plugin_name, db_file_name) if upgrade_mod: try: @@ -248,10 +245,13 @@ class Manager(object): 'not be loaded.\n\nDatabase: %s') % (db_ver, up_ver, self.db_url) ) return - try: - self.session = init_schema(self.db_url) - except (SQLAlchemyError, DBAPIError): - handle_db_error(plugin_name, db_file_name) + if not session: + try: + self.session = init_schema(self.db_url) + except (SQLAlchemyError, DBAPIError): + handle_db_error(plugin_name, db_file_name) + else: + self.session = session def save_object(self, object_instance, commit=True): """ @@ -344,13 +344,13 @@ class Manager(object): for try_count in range(3): try: return self.session.query(object_class).filter(filter_clause).first() - except OperationalError: + except OperationalError as oe: # This exception clause is for users running MySQL which likes to terminate connections on its own # without telling anyone. See bug #927473. However, other dbms can raise it, usually in a # non-recoverable way. So we only retry 3 times. - log.exception('Probably a MySQL issue, "MySQL has gone away"') - if try_count >= 2: + if try_count >= 2 or 'MySQL has gone away' in str(oe): raise + log.exception('Probably a MySQL issue, "MySQL has gone away"') def get_all_objects(self, object_class, filter_clause=None, order_by_ref=None): """ diff --git a/openlp/core/lib/projector/db.py b/openlp/core/lib/projector/db.py index 670c9e31b..3e050bf22 100644 --- a/openlp/core/lib/projector/db.py +++ b/openlp/core/lib/projector/db.py @@ -20,18 +20,18 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ - :mod:`openlp.core.lib.projector.db` module +:mod:`openlp.core.lib.projector.db` module - Provides the database functions for the Projector module. +Provides the database functions for the Projector module. - The Manufacturer, Model, Source tables keep track of the video source - strings used for display of input sources. The Source table maps - manufacturer-defined or user-defined strings from PJLink default strings - to end-user readable strings; ex: PJLink code 11 would map "RGB 1" - default string to "RGB PC (analog)" string. - (Future feature). +The Manufacturer, Model, Source tables keep track of the video source +strings used for display of input sources. The Source table maps +manufacturer-defined or user-defined strings from PJLink default strings +to end-user readable strings; ex: PJLink code 11 would map "RGB 1" +default string to "RGB PC (analog)" string. +(Future feature). - The Projector table keeps track of entries for controlled projectors. +The Projector table keeps track of entries for controlled projectors. """ import logging @@ -218,19 +218,19 @@ class ProjectorDB(Manager): """ def __init__(self, *args, **kwargs): log.debug('ProjectorDB().__init__(args="%s", kwargs="%s")' % (args, kwargs)) - super().__init__(plugin_name='projector', - init_schema=self.init_schema) + super().__init__(plugin_name='projector', init_schema=self.init_schema) log.debug('ProjectorDB() Initialized using db url %s' % self.db_url) + log.debug('Session: %s', self.session) - def init_schema(*args, **kwargs): + def init_schema(self, *args, **kwargs): """ Setup the projector database and initialize the schema. Declarative uses table classes to define schema. """ - url = init_url('projector') - session, metadata = init_db(url, base=Base) - Base.metadata.create_all(checkfirst=True) + self.db_url = init_url('projector') + session, metadata = init_db(self.db_url, base=Base) + metadata.create_all(checkfirst=True) return session def get_projector_by_id(self, dbid): diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index a6902ad2c..0105caa07 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -25,12 +25,12 @@ record functions. PREREQUISITE: add_record() and get_all() functions validated. """ - +import os from unittest import TestCase -from tests.functional import MagicMock, patch from openlp.core.lib.projector.db import Projector, ProjectorDB, ProjectorSource +from tests.functional import MagicMock, patch from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA tmpfile = '/tmp/openlp-test-projectordb.sql' @@ -60,15 +60,15 @@ def compare_source(one, two): one.text == two.text -def add_records(self, test): +def add_records(projector_db, test): """ Add record if not in database """ - record_list = self.projector.get_projector_all() + record_list = projector_db.get_projector_all() if len(record_list) < 1: added = False for record in test: - added = self.projector.add_projector(record) or added + added = projector_db.add_projector(record) or added return added for new_record in test: @@ -76,7 +76,7 @@ def add_records(self, test): for record in record_list: if compare_data(record, new_record): break - added = self.projector.add_projector(new_record) + added = projector_db.add_projector(new_record) return added @@ -88,10 +88,11 @@ class TestProjectorDB(TestCase): """ Set up anything necessary for all tests """ - if not hasattr(self, 'projector'): - with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: - mocked_init_url.return_value = 'sqlite:///%s' % tmpfile - self.projector = ProjectorDB() + with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: + if os.path.exists(tmpfile): + os.unlink(tmpfile) + mocked_init_url.return_value = 'sqlite:///%s' % tmpfile + self.projector = ProjectorDB() def tearDown(self): """ @@ -104,7 +105,7 @@ class TestProjectorDB(TestCase): Test find record by IP """ # GIVEN: Record entries in database - add_records(self, [TEST1_DATA, TEST2_DATA]) + add_records(self.projector, [TEST1_DATA, TEST2_DATA]) # WHEN: Search for record using IP record = self.projector.get_projector_by_ip(TEST2_DATA.ip) @@ -118,7 +119,7 @@ class TestProjectorDB(TestCase): Test find record by name """ # GIVEN: Record entries in database - add_records(self, [TEST1_DATA, TEST2_DATA]) + add_records(self.projector, [TEST1_DATA, TEST2_DATA]) # WHEN: Search for record using name record = self.projector.get_projector_by_name(TEST2_DATA.name) @@ -132,7 +133,7 @@ class TestProjectorDB(TestCase): Test record can be deleted """ # GIVEN: Record in database - add_records(self, [TEST3_DATA, ]) + add_records(self.projector, [TEST3_DATA, ]) record = self.projector.get_projector_by_ip(TEST3_DATA.ip) # WHEN: Record deleted @@ -147,7 +148,7 @@ class TestProjectorDB(TestCase): Test edited record returns the same record ID with different data """ # GIVEN: Record entries in database - add_records(self, [TEST1_DATA, TEST2_DATA]) + add_records(self.projector, [TEST1_DATA, TEST2_DATA]) # WHEN: We retrieve a specific record record = self.projector.get_projector_by_ip(TEST1_DATA.ip) From 7ebbf65a86c22f8a4e718148ef0f4fd0d8b1ed4e Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Thu, 7 Jan 2016 13:36:11 +0100 Subject: [PATCH 16/22] Add a test --- .../openlp_core_lib/test_mediamanageritem.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_mediamanageritem.py b/tests/functional/openlp_core_lib/test_mediamanageritem.py index 848f34233..a3674f591 100644 --- a/tests/functional/openlp_core_lib/test_mediamanageritem.py +++ b/tests/functional/openlp_core_lib/test_mediamanageritem.py @@ -60,6 +60,22 @@ class TestMediaManagerItem(TestCase, TestMixin): # THEN: on_preview_click() should have been called mocked_on_preview_click.assert_called_with() + def required_icons_test(self): + """ + Test the default icons for plugins + """ + # GIVEN: A MediaManagerItem + mmi = MediaManagerItem(None) + # WHEN: Object is created + mmi.required_icons() + # THEN: Default icons should be populated + self.assertFalse(mmi.has_import_icon, 'There should be no import icon by default') + self.assertTrue(mmi.has_new_icon, 'By default a new icon should be present') + self.assertFalse(mmi.has_file_icon, 'There should be no file icon by default') + self.assertTrue(mmi.has_delete_icon, 'By default a delete icon should be present') + self.assertFalse(mmi.add_to_service_item, 'There should be no add_to_service icon by default') + + @patch(u'openlp.core.lib.mediamanageritem.Settings') @patch(u'openlp.core.lib.mediamanageritem.MediaManagerItem.on_live_click') def on_double_clicked_go_live_test(self, mocked_on_live_click, MockedSettings): From f2cccb90ae58e11333ec0547e4f36e7c82f726d1 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 7 Jan 2016 23:07:55 +0200 Subject: [PATCH 17/22] Fix projector tests --- tests/functional/openlp_core_lib/__init__.py | 23 -------- .../openlp_core_lib/test_projectordb.py | 54 +++++++++---------- tests/resources/projector/data.py | 40 +++++++------- 3 files changed, 47 insertions(+), 70 deletions(-) diff --git a/tests/functional/openlp_core_lib/__init__.py b/tests/functional/openlp_core_lib/__init__.py index 4d7b64522..2b1b9c60a 100644 --- a/tests/functional/openlp_core_lib/__init__.py +++ b/tests/functional/openlp_core_lib/__init__.py @@ -22,26 +22,3 @@ """ Module-level functions for the functional test suite """ - -import os -from tests.functional import patch - -from openlp.core.common import is_win - -from .test_projectordb import tmpfile - - -def setUp(): - if not is_win(): - # Wine creates a sharing violation during tests. Ignore. - try: - os.remove(tmpfile) - except: - pass - - -def tearDown(): - """ - Ensure test suite has been cleaned up after tests - """ - patch.stopall() diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index 0105caa07..dd61bf33b 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -31,9 +31,7 @@ from unittest import TestCase from openlp.core.lib.projector.db import Projector, ProjectorDB, ProjectorSource from tests.functional import MagicMock, patch -from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA - -tmpfile = '/tmp/openlp-test-projectordb.sql' +from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA def compare_data(one, two): @@ -89,9 +87,9 @@ class TestProjectorDB(TestCase): Set up anything necessary for all tests """ with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: - if os.path.exists(tmpfile): - os.unlink(tmpfile) - mocked_init_url.return_value = 'sqlite:///%s' % tmpfile + if os.path.exists(TEST_DB): + os.unlink(TEST_DB) + mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB self.projector = ProjectorDB() def tearDown(self): @@ -105,13 +103,13 @@ class TestProjectorDB(TestCase): Test find record by IP """ # GIVEN: Record entries in database - add_records(self.projector, [TEST1_DATA, TEST2_DATA]) + add_records(self.projector, [Projector(**TEST1_DATA), Projector(**TEST2_DATA)]) # WHEN: Search for record using IP - record = self.projector.get_projector_by_ip(TEST2_DATA.ip) + record = self.projector.get_projector_by_ip(TEST2_DATA['ip']) # THEN: Verify proper record returned - self.assertTrue(compare_data(TEST2_DATA, record), + self.assertTrue(compare_data(Projector(**TEST2_DATA), record), 'Record found should have been test_2 data') def find_record_by_name_test(self): @@ -119,13 +117,13 @@ class TestProjectorDB(TestCase): Test find record by name """ # GIVEN: Record entries in database - add_records(self.projector, [TEST1_DATA, TEST2_DATA]) + add_records(self.projector, [Projector(**TEST1_DATA), Projector(**TEST2_DATA)]) # WHEN: Search for record using name - record = self.projector.get_projector_by_name(TEST2_DATA.name) + record = self.projector.get_projector_by_name(TEST2_DATA['name']) # THEN: Verify proper record returned - self.assertTrue(compare_data(TEST2_DATA, record), + self.assertTrue(compare_data(Projector(**TEST2_DATA), record), 'Record found should have been test_2 data') def record_delete_test(self): @@ -133,14 +131,14 @@ class TestProjectorDB(TestCase): Test record can be deleted """ # GIVEN: Record in database - add_records(self.projector, [TEST3_DATA, ]) - record = self.projector.get_projector_by_ip(TEST3_DATA.ip) + add_records(self.projector, [Projector(**TEST3_DATA), ]) + record = self.projector.get_projector_by_ip(TEST3_DATA['ip']) # WHEN: Record deleted self.projector.delete_projector(record) # THEN: Verify record not retrievable - found = self.projector.get_projector_by_ip(TEST3_DATA.ip) + found = self.projector.get_projector_by_ip(TEST3_DATA['ip']) self.assertFalse(found, 'test_3 record should have been deleted') def record_edit_test(self): @@ -148,34 +146,35 @@ class TestProjectorDB(TestCase): Test edited record returns the same record ID with different data """ # GIVEN: Record entries in database - add_records(self.projector, [TEST1_DATA, TEST2_DATA]) + add_records(self.projector, [Projector(**TEST1_DATA), Projector(**TEST2_DATA)]) # WHEN: We retrieve a specific record - record = self.projector.get_projector_by_ip(TEST1_DATA.ip) + record = self.projector.get_projector_by_ip(TEST1_DATA['ip']) record_id = record.id # WHEN: Data is changed - record.ip = TEST3_DATA.ip - record.port = TEST3_DATA.port - record.pin = TEST3_DATA.pin - record.name = TEST3_DATA.name - record.location = TEST3_DATA.location - record.notes = TEST3_DATA.notes + record.ip = TEST3_DATA['ip'] + record.port = TEST3_DATA['port'] + record.pin = TEST3_DATA['pin'] + record.name = TEST3_DATA['name'] + record.location = TEST3_DATA['location'] + record.notes = TEST3_DATA['notes'] updated = self.projector.update_projector(record) self.assertTrue(updated, 'Save updated record should have returned True') - record = self.projector.get_projector_by_ip(TEST3_DATA.ip) + record = self.projector.get_projector_by_ip(TEST3_DATA['ip']) # THEN: Record ID should remain the same, but data should be changed self.assertEqual(record_id, record.id, 'Edited record should have the same ID') - self.assertTrue(compare_data(TEST3_DATA, record), 'Edited record should have new data') + self.assertTrue(compare_data(Projector(**TEST3_DATA), record), 'Edited record should have new data') def source_add_test(self): """ Test source entry for projector item """ # GIVEN: Record entries in database - self.projector.add_projector(TEST1_DATA) - item = self.projector.get_projector_by_id(TEST1_DATA.id) + projector1 = Projector(**TEST1_DATA) + self.projector.add_projector(projector1) + item = self.projector.get_projector_by_id(projector1.id) item_id = item.id # WHEN: A source entry is saved for item @@ -185,3 +184,4 @@ class TestProjectorDB(TestCase): # THEN: Projector should have the same source entry item = self.projector.get_projector_by_id(item_id) self.assertTrue(compare_source(item.source_list[0], source)) + diff --git a/tests/resources/projector/data.py b/tests/resources/projector/data.py index c8101bea1..97739c7e9 100644 --- a/tests/resources/projector/data.py +++ b/tests/resources/projector/data.py @@ -24,28 +24,28 @@ The :mod:`tests.resources.projector.data file contains test data """ import os -from openlp.core.lib.projector.db import Projector +from tempfile import gettempdir # Test data -TEST_DB = os.path.join('tmp', 'openlp-test-projectordb.sql') +TEST_DB = os.path.join(gettempdir(), 'openlp-test-projectordb.sql') -TEST1_DATA = Projector(ip='111.111.111.111', - port='1111', - pin='1111', - name='___TEST_ONE___', - location='location one', - notes='notes one') +TEST1_DATA = dict(ip='111.111.111.111', + port='1111', + pin='1111', + name='___TEST_ONE___', + location='location one', + notes='notes one') -TEST2_DATA = Projector(ip='222.222.222.222', - port='2222', - pin='2222', - name='___TEST_TWO___', - location='location two', - notes='notes two') +TEST2_DATA = dict(ip='222.222.222.222', + port='2222', + pin='2222', + name='___TEST_TWO___', + location='location two', + notes='notes two') -TEST3_DATA = Projector(ip='333.333.333.333', - port='3333', - pin='3333', - name='___TEST_THREE___', - location='location three', - notes='notes three') +TEST3_DATA = dict(ip='333.333.333.333', + port='3333', + pin='3333', + name='___TEST_THREE___', + location='location three', + notes='notes three') From 543d6898d3716f882f4c6cd933eedad647448c1f Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 7 Jan 2016 23:36:43 +0200 Subject: [PATCH 18/22] Fix up the projector interface tests --- .../openlp_core_ui/test_projectoreditform.py | 14 ++++++++----- .../test_projectorsourceform.py | 20 ++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/tests/interfaces/openlp_core_ui/test_projectoreditform.py b/tests/interfaces/openlp_core_ui/test_projectoreditform.py index a7adbed6c..0f42e38ae 100644 --- a/tests/interfaces/openlp_core_ui/test_projectoreditform.py +++ b/tests/interfaces/openlp_core_ui/test_projectoreditform.py @@ -23,7 +23,7 @@ Interface tests to test the openlp.core.ui.projector.editform.ProjectorEditForm() class and methods. """ - +import os from unittest import TestCase from openlp.core.common import Registry, Settings @@ -32,7 +32,7 @@ from openlp.core.ui import ProjectorEditForm from tests.functional import patch from tests.helpers.testmixin import TestMixin -from tests.resources.projector.data import TEST1_DATA, TEST2_DATA +from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA class TestProjectorEditForm(TestCase, TestMixin): @@ -49,7 +49,9 @@ class TestProjectorEditForm(TestCase, TestMixin): self.setup_application() Registry.create() with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: - mocked_init_url.return_value = 'sqlite://' + if os.path.exists(TEST_DB): + os.unlink(TEST_DB) + mocked_init_url.return_value = 'sqlite:///' + TEST_DB self.projectordb = ProjectorDB() self.projector_form = ProjectorEditForm(projectordb=self.projectordb) @@ -93,11 +95,13 @@ class TestProjectorEditForm(TestCase, TestMixin): with patch('openlp.core.ui.projector.editform.QDialog.exec'): # WHEN: Calling edit form with existing projector instance - self.projector_form.exec(projector=TEST1_DATA) + self.projector_form.exec(projector=Projector(**TEST1_DATA)) item = self.projector_form.projector # THEN: Should be editing an existing entry self.assertFalse(self.projector_form.new_projector, 'Projector edit form should be marked as existing entry') - self.assertTrue((item.ip is TEST1_DATA.ip and item.name is TEST1_DATA.name), + self.assertTrue((item.ip is TEST1_DATA['ip'] and item.name is TEST1_DATA['name']), 'Projector edit form should have TEST1_DATA() instance to edit') + + diff --git a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py index 204520c38..b4951e910 100644 --- a/tests/interfaces/openlp_core_ui/test_projectorsourceform.py +++ b/tests/interfaces/openlp_core_ui/test_projectorsourceform.py @@ -20,24 +20,24 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ - :mod: `tests.interfaces.openlp_core_ui.test_projectorsourceform` module +:mod: `tests.interfaces.openlp_core_ui.test_projectorsourceform` module - Tests for the Projector Source Select form. +Tests for the Projector Source Select form. """ import logging log = logging.getLogger(__name__) log.debug('test_projectorsourceform loaded') - +import os from unittest import TestCase + from PyQt5.QtWidgets import QDialog from tests.functional import patch -from tests.functional.openlp_core_lib.test_projectordb import tmpfile from tests.helpers.testmixin import TestMixin from tests.resources.projector.data import TEST_DB, TEST1_DATA from openlp.core.common import Registry, Settings -from openlp.core.lib.projector.db import ProjectorDB +from openlp.core.lib.projector.db import ProjectorDB, Projector from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle @@ -65,7 +65,9 @@ class ProjectorSourceFormTest(TestCase, TestMixin): """ Set up anything necessary for all tests """ - mocked_init_url.return_value = 'sqlite:///{}'.format(tmpfile) + if os.path.exists(TEST_DB): + os.unlink(TEST_DB) + mocked_init_url.return_value = 'sqlite:///{}'.format(TEST_DB) self.build_settings() self.setup_application() Registry.create() @@ -73,10 +75,10 @@ class ProjectorSourceFormTest(TestCase, TestMixin): if not hasattr(self, 'projectordb'): self.projectordb = ProjectorDB() # Retrieve/create a database record - self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA.ip) + self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA['ip']) if not self.projector: - self.projectordb.add_projector(projector=TEST1_DATA) - self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA.ip) + self.projectordb.add_projector(projector=Projector(**TEST1_DATA)) + self.projector = self.projectordb.get_projector_by_ip(TEST1_DATA['ip']) self.projector.dbid = self.projector.id self.projector.db_item = self.projector From 7853706479d3a0b9b98283e4bdac5b7f508052f9 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 7 Jan 2016 23:38:13 +0200 Subject: [PATCH 19/22] Apparently BibleServer.com has removed that Bible. Use another one instead. --- tests/interfaces/openlp_plugins/bibles/test_lib_http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py index 0260b1db7..ca2269aa4 100644 --- a/tests/interfaces/openlp_plugins/bibles/test_lib_http.py +++ b/tests/interfaces/openlp_plugins/bibles/test_lib_http.py @@ -130,7 +130,7 @@ class TestBibleHTTP(TestCase): # THEN: The list should not be None, and some known bibles should be there self.assertIsNotNone(bibles) self.assertIn(('New Int. Readers Version', 'NIRV', 'en'), bibles) - self.assertIn(('Българската Библия', 'BLG', 'bg'), bibles) + self.assertIn(('Священное Писание, Восточный перевод', 'CARS', 'ru'), bibles) def biblegateway_get_bibles_test(self): """ From a61430a59f3f491eb54a5d88c3efa986b5e40a79 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Thu, 7 Jan 2016 23:57:01 +0200 Subject: [PATCH 20/22] Fix the tests on Windows too --- .../openlp_core_lib/test_projectordb.py | 1 + .../openlp_core_ui/test_projectormanager.py | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/functional/openlp_core_lib/test_projectordb.py b/tests/functional/openlp_core_lib/test_projectordb.py index dd61bf33b..3559e9e8c 100644 --- a/tests/functional/openlp_core_lib/test_projectordb.py +++ b/tests/functional/openlp_core_lib/test_projectordb.py @@ -96,6 +96,7 @@ class TestProjectorDB(TestCase): """ Clean up """ + self.projector.session.close() self.projector = None def find_record_by_ip_test(self): diff --git a/tests/interfaces/openlp_core_ui/test_projectormanager.py b/tests/interfaces/openlp_core_ui/test_projectormanager.py index b41d23ac7..695a25586 100644 --- a/tests/interfaces/openlp_core_ui/test_projectormanager.py +++ b/tests/interfaces/openlp_core_ui/test_projectormanager.py @@ -22,7 +22,6 @@ """ Interface tests to test the themeManager class and related methods. """ - import os from unittest import TestCase @@ -33,9 +32,7 @@ from tests.helpers.testmixin import TestMixin from openlp.core.ui import ProjectorManager, ProjectorEditForm from openlp.core.lib.projector.db import Projector, ProjectorDB -from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA - -tmpfile = '/tmp/openlp-test-projectormanager.sql' +from tests.resources.projector.data import TEST_DB, TEST1_DATA, TEST2_DATA, TEST3_DATA class TestProjectorManager(TestCase, TestMixin): @@ -49,12 +46,13 @@ class TestProjectorManager(TestCase, TestMixin): self.build_settings() self.setup_application() Registry.create() - if not hasattr(self, 'projector_manager'): - with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: - mocked_init_url.return_value = 'sqlite:///%s' % tmpfile - self.projectordb = ProjectorDB() - if not hasattr(self, 'projector_manager'): - self.projector_manager = ProjectorManager(projectordb=self.projectordb) + with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url: + if os.path.exists(TEST_DB): + os.unlink(TEST_DB) + mocked_init_url.return_value = 'sqlite:///%s' % TEST_DB + self.projectordb = ProjectorDB() + if not hasattr(self, 'projector_manager'): + self.projector_manager = ProjectorManager(projectordb=self.projectordb) def tearDown(self): """ From c4bb673ac01713f2444cb57327982e0d663e7450 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 8 Jan 2016 00:00:02 +0200 Subject: [PATCH 21/22] Remove potentially unnecessary code --- tests/interfaces/openlp_core_ui/__init__.py | 32 --------------------- 1 file changed, 32 deletions(-) diff --git a/tests/interfaces/openlp_core_ui/__init__.py b/tests/interfaces/openlp_core_ui/__init__.py index 5eb206b6c..2b1b9c60a 100644 --- a/tests/interfaces/openlp_core_ui/__init__.py +++ b/tests/interfaces/openlp_core_ui/__init__.py @@ -22,35 +22,3 @@ """ Module-level functions for the functional test suite """ - -import os - -from openlp.core.common import is_win - -from tests.interfaces import patch -from .test_projectormanager import tmpfile - - -def setUp(): - """ - Set up this module of tests - """ - if not is_win(): - # Wine creates a sharing violation during tests. Ignore. - try: - os.remove(tmpfile) - except: - pass - - -def tearDown(): - """ - Ensure test suite has been cleaned up after tests - """ - patch.stopall() - if not is_win(): - try: - # In case of changed schema, remove old test file - os.remove(tmpfile) - except FileNotFoundError: - pass From 4fd53706c63ce7eb6d31cee81493748ffe5d84a9 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 8 Jan 2016 00:18:01 +0200 Subject: [PATCH 22/22] We still need a db_url. Thanks interface tests! --- openlp/core/lib/db.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 6eb67b5df..d63dee23c 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -231,6 +231,8 @@ class Manager(object): if db_file_name: log.debug('Manager: Creating new DB url') self.db_url = init_url(plugin_name, db_file_name) + else: + self.db_url = init_url(plugin_name) if upgrade_mod: try: db_ver, up_ver = upgrade_db(self.db_url, upgrade_mod)