Improve help

This commit is contained in:
robbie jackson 2021-08-25 21:14:19 +00:00 committed by Tim Bentley
parent e048348890
commit 2907cb4f14
30 changed files with 371 additions and 25 deletions

View File

@ -87,6 +87,8 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
buttons |= QtWidgets.QDialogButtonBox.Cancel
if 'close' in standard_buttons:
buttons |= QtWidgets.QDialogButtonBox.Close
if 'help' in standard_buttons and hasattr(dialog, 'provide_help'):
buttons |= QtWidgets.QDialogButtonBox.Help
if 'defaults' in standard_buttons:
buttons |= QtWidgets.QDialogButtonBox.RestoreDefaults
button_box = QtWidgets.QDialogButtonBox(dialog)
@ -99,6 +101,8 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None):
button_box.addButton(*button)
button_box.accepted.connect(dialog.accept)
button_box.rejected.connect(dialog.reject)
if 'help' in standard_buttons and hasattr(dialog, 'provide_help'):
button_box.helpRequested.connect(dialog.provide_help)
return button_box

View File

@ -30,7 +30,7 @@ import urllib.request
from pathlib import Path
from tempfile import gettempdir
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.api.deploy import get_latest_size, download_and_check
from openlp.core.common import trace_error_handler
@ -100,7 +100,8 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
"""
Create and set up the first time wizard.
"""
super(FirstTimeForm, self).__init__(parent)
super(FirstTimeForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint |
QtCore.Qt.WindowCloseButtonHint)
self.has_web_access = True
self.web = ''
self.is_index_downloaded = False
@ -109,6 +110,14 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
self.themes_list_widget.itemSelectionChanged.connect(self.on_themes_list_widget_selection_changed)
self.themes_deselect_all_button.clicked.connect(self.themes_list_widget.clearSelection)
self.themes_select_all_button.clicked.connect(self.themes_list_widget.selectAll)
self.setOption(QtWidgets.QWizard.HaveHelpButton, True)
self.helpRequested.connect(self.provide_help)
def provide_help(self):
"""
Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/wizard.html"))
def get_next_page_id(self):
"""

View File

@ -51,7 +51,7 @@ class Ui_SettingsDialog(object):
self.stacked_layout = QtWidgets.QStackedLayout()
self.stacked_layout.setObjectName('stacked_layout')
self.dialog_layout.addLayout(self.stacked_layout, 0, 1, 1, 1)
self.button_box = create_button_box(settings_dialog, 'button_box', ['cancel', 'ok'])
self.button_box = create_button_box(settings_dialog, 'button_box', ['cancel', 'ok', 'help'])
self.dialog_layout.addWidget(self.button_box, 1, 1, 1, 1)
self.retranslate_ui(settings_dialog)

View File

@ -23,7 +23,7 @@ The :mod:`settingsform` provides a user interface for the OpenLP settings
"""
import logging
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.state import State
from openlp.core.api.tab import ApiTab
@ -210,3 +210,9 @@ class SettingsForm(QtWidgets.QDialog, Ui_SettingsDialog, RegistryProperties):
"""
if function not in self.processes:
self.processes.append(function)
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/configure.html"))

View File

@ -52,7 +52,8 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
:param parent: The QWidget-derived parent of the wizard.
"""
super(ThemeForm, self).__init__(parent)
super(ThemeForm, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint |
QtCore.Qt.WindowCloseButtonHint)
self._setup()
def _setup(self):
@ -75,6 +76,14 @@ class ThemeForm(QtWidgets.QWizard, Ui_ThemeWizard, RegistryProperties):
self.main_area_page.shadow_size_changed.connect(self.calculate_lines)
self.footer_area_page.font_name_changed.connect(self.update_theme)
self.footer_area_page.font_size_changed.connect(self.update_theme)
self.setOption(QtWidgets.QWizard.HaveHelpButton, True)
self.helpRequested.connect(self.provide_help)
def provide_help(self):
"""
Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/themes.html"))
def set_defaults(self):
"""

View File

@ -125,6 +125,10 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties):
self.setModal(True)
self.setOptions(QtWidgets.QWizard.IndependentPages |
QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.NoBackButtonOnLastPage)
# Set up a help button if the class of this instance has overridden the provide_help method
if (self.provide_help.__module__ != __name__):
self.setOption(QtWidgets.QWizard.HaveHelpButton, True)
self.helpRequested.connect(self.provide_help)
if is_macosx():
self.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
else:
@ -277,3 +281,9 @@ class OpenLPWizard(QtWidgets.QWizard, RegistryProperties):
self.finish_button.setVisible(True)
self.cancel_button.setVisible(False)
self.application.process_events()
def provide_help(self):
"""
Provide help - usually by opening the appropriate page of the openlp manual in the user's browser
"""
pass

View File

@ -79,7 +79,7 @@ class AlertDialog(object):
self.display_button = create_button(alert_dialog, 'display_button', icon=UiIcons().live, enabled=False)
self.display_close_button = create_button(alert_dialog, 'display_close_button', icon=UiIcons().live,
enabled=False)
self.button_box = create_button_box(alert_dialog, 'button_box', ['close'],
self.button_box = create_button_box(alert_dialog, 'button_box', ['close', 'help'],
[self.display_button, self.display_close_button])
self.alert_dialog_layout.addWidget(self.button_box, 2, 0, 1, 2)
self.retranslate_ui(alert_dialog)

View File

@ -19,7 +19,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.common.i18n import translate
from openlp.core.common.registry import Registry
@ -217,3 +217,9 @@ class AlertForm(QtWidgets.QDialog, AlertDialog):
self.delete_button.setEnabled(True)
# We do not need to enable the save button, as it is only enabled
# when typing text in the "alert_text_edit".
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/alert.html"))

View File

@ -25,7 +25,7 @@ import logging
import urllib.error
from lxml import etree
from PyQt5 import QtWidgets
from PyQt5 import QtWidgets, QtGui, QtCore
try:
from pysword import modules
@ -773,3 +773,9 @@ class BibleImportForm(OpenLPWizard):
# Don't delete the db if it wasen't created
if hasattr(importer, 'file'):
delete_database(self.plugin.settings_section, importer.file)
def provide_help(self):
"""
Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/bibles.html"))

View File

@ -123,7 +123,7 @@ class Ui_EditBibleDialog(object):
self.bible_tab_widget.addTab(self.book_name_tab, '')
# Last few bits
self.dialog_layout.addWidget(self.bible_tab_widget)
self.button_box = create_button_box(edit_bible_dialog, 'button_box', ['cancel', 'save'])
self.button_box = create_button_box(edit_bible_dialog, 'button_box', ['cancel', 'save', 'help'])
self.dialog_layout.addWidget(self.button_box)
self.retranslate_ui(edit_bible_dialog)
QtCore.QMetaObject.connectSlotsByName(edit_bible_dialog)

View File

@ -22,7 +22,7 @@
import logging
import re
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties
@ -213,3 +213,9 @@ class EditBibleForm(QtWidgets.QDialog, Ui_EditBibleDialog, RegistryProperties):
'The Book Name "{name}" has been entered more than once.').format(name=new_book_name))
return False
return True
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/bibles.html#edit-bible-data"))

View File

@ -94,7 +94,7 @@ class Ui_CustomEditDialog(object):
self.bottom_form_layout.addRow(self.credit_label, self.credit_edit)
self.dialog_layout.addLayout(self.bottom_form_layout)
self.preview_button = QtWidgets.QPushButton()
self.button_box = create_button_box(custom_edit_dialog, 'button_box', ['cancel', 'save'],
self.button_box = create_button_box(custom_edit_dialog, 'button_box', ['cancel', 'save', 'help'],
[self.preview_button])
self.save_button = self.button_box.button(QtWidgets.QDialogButtonBox.Save)
self.dialog_layout.addWidget(self.button_box)

View File

@ -21,7 +21,7 @@
import logging
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.common.i18n import translate
from openlp.core.common.registry import Registry
@ -244,3 +244,9 @@ class EditCustomForm(QtWidgets.QDialog, Ui_CustomEditDialog):
'You need to add at least one slide.'))
return False
return True
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/custom_slides.html"))

View File

@ -289,7 +289,7 @@ class Ui_EditSongDialog(object):
self.warning_label = QtWidgets.QLabel(edit_song_dialog)
self.warning_label.setObjectName('warning_label')
self.bottom_layout.addWidget(self.warning_label)
self.button_box = create_button_box(edit_song_dialog, 'button_box', ['cancel', 'save'])
self.button_box = create_button_box(edit_song_dialog, 'button_box', ['cancel', 'save', 'help'])
self.bottom_layout.addWidget(self.button_box)
self.dialog_layout.addLayout(self.bottom_layout)
self.retranslate_ui(edit_song_dialog)

View File

@ -26,7 +26,7 @@ import logging
import re
from shutil import copyfile
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.state import State
from openlp.core.common.applocation import AppLocation
@ -1099,3 +1099,10 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties):
clean_song(self.manager, self.song)
self.manager.save_object(self.song)
self.media_item.auto_select_id = self.song.id
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/songs.html#creating-or-editing-a-song"
"-slide"))

View File

@ -24,7 +24,7 @@ OpenLyrics format.
"""
import logging
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.registry import Registry
@ -290,6 +290,12 @@ class SongExportForm(OpenLPWizard):
if not item.isHidden():
item.setCheckState(QtCore.Qt.Checked)
def provide_help(self):
"""
Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/export_songs.html"))
def find_list_widget_items(list_widget, text=''):
"""

View File

@ -23,7 +23,7 @@ The song import functions for OpenLP.
"""
import logging
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.common.i18n import UiStrings, translate
from openlp.core.common.mixins import RegistryProperties
@ -463,6 +463,12 @@ class SongImportForm(OpenLPWizard, RegistryProperties):
self.format_widgets[this_format]['import_widget'] = import_widget
return import_widget
def provide_help(self):
"""
Provide help within the wizard by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/songs.html#song-importer"))
class SongImportSourcePage(QtWidgets.QWizardPage):
"""

View File

@ -52,7 +52,7 @@ class Ui_SongUsageDeleteDialog(object):
self.delete_calendar.setVerticalHeaderFormat(QtWidgets.QCalendarWidget.NoVerticalHeader)
self.delete_calendar.setObjectName('delete_calendar')
self.vertical_layout.addWidget(self.delete_calendar)
self.button_box = create_button_box(song_usage_delete_dialog, 'button_box', ['cancel', 'ok'])
self.button_box = create_button_box(song_usage_delete_dialog, 'button_box', ['cancel', 'ok', 'help'])
self.vertical_layout.addWidget(self.button_box)
self.retranslate_ui(song_usage_delete_dialog)

View File

@ -19,7 +19,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from openlp.core.common.i18n import translate
from openlp.core.common.mixins import RegistryProperties
@ -65,3 +65,9 @@ class SongUsageDeleteForm(QtWidgets.QDialog, Ui_SongUsageDeleteDialog, RegistryP
self.accept()
else:
self.reject()
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/song_usage.html"))

View File

@ -71,7 +71,7 @@ class Ui_SongUsageDetailDialog(object):
self.report_path_edit = PathEdit(self.file_group_box, path_type=PathEditType.Directories, show_revert=False)
self.file_horizontal_layout.addWidget(self.report_path_edit)
self.vertical_layout.addWidget(self.file_group_box)
self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok'])
self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok', 'help'])
self.vertical_layout.addWidget(self.button_box)
self.retranslate_ui(song_usage_detail_dialog)
self.report_path_edit.pathChanged.connect(song_usage_detail_dialog.on_report_path_edit_path_changed)

View File

@ -20,7 +20,7 @@
##########################################################################
import logging
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtGui
from sqlalchemy.sql import and_
from openlp.core.common.i18n import translate
@ -119,3 +119,9 @@ class SongUsageDetailForm(QtWidgets.QDialog, Ui_SongUsageDetailDialog, RegistryP
'An error occurred while creating the report: {error}'
).format(error=ose.strerror))
self.close()
def provide_help(self):
"""
Provide help within the form by opening the appropriate page of the openlp manual in the user's browser
"""
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://manual.openlp.org/song_usage.html"))

View File

@ -25,7 +25,7 @@ import pytest
from pathlib import Path
from unittest.mock import MagicMock, call, patch, DEFAULT
from PyQt5 import QtCore, QtWidgets
from PyQt5 import QtCore, QtWidgets, QtTest
from openlp.core.common.registry import Registry
from openlp.core.ui.firsttimeform import FirstTimeForm, ThemeListWidgetItem
@ -482,3 +482,18 @@ def test_successful_download(mocked_build_icon, mocked_set_icon):
# THEN: An icon should have been built from the downloaded file and used to replace the loading icon
mocked_build_icon.assert_called_once_with(test_path)
mocked_set_icon.assert_has_calls([call(UiIcons().picture), call(mocked_build_icon())])
@patch.object(FirstTimeForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: A First Time Wizard and a patched help function
frw = FirstTimeForm(None)
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(frw.button(QtWidgets.QWizard.HelpButton), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -23,7 +23,7 @@ Package to test the openlp.core.ui.settingsform package.
"""
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets
from PyQt5 import QtCore, QtWidgets, QtTest
from openlp.core.ui.settingsform import SettingsForm
@ -167,3 +167,18 @@ def test_register_post_process(registry):
# THEN: The fake function should be in the settings form's list
assert fake_function in settings_form.processes
@patch.object(SettingsForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: An initialised Settings form and a patched help function
settings_form = SettingsForm(None)
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(settings_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2021 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
Package to test the openlp.plugins.alerts.forms.alertform package.
"""
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets, QtTest, QtCore
from openlp.plugins.alerts.forms.alertform import AlertForm
@patch.object(AlertForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: An alert form and a patched help function
alert_form = AlertForm(MagicMock())
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(alert_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -24,7 +24,7 @@ Package to test the openlp.plugins.bibles.forms.bibleimportform package.
from unittest import TestCase, skip
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets
from PyQt5 import QtWidgets, QtTest, QtCore
from openlp.core.common.registry import Registry
from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm
@ -89,3 +89,17 @@ class TestBibleImportForm(TestCase, TestMixin):
# THEN: sword_tab_widget.setDisabled(True) should have been called
self.form.sword_tab_widget.setDisabled.assert_called_with(True)
@patch.object(BibleImportForm, 'provide_help')
def test_help(self, mocked_help, settings):
"""
Test the help button
"""
# GIVEN: A bible import wizard and a patched help function
bible_import_form = BibleImportForm(None, MagicMock(), None)
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(bible_import_form.button(QtWidgets.QWizard.HelpButton), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2021 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
Package to test the openlp.plugins.bibles.forms.editbibleform package.
"""
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets, QtTest, QtCore
from openlp.plugins.bibles.forms.editbibleform import EditBibleForm
@patch.object(EditBibleForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: An edit bible form and a patched help function
main_window = QtWidgets.QMainWindow()
edit_bible_form = EditBibleForm(MagicMock(), main_window, MagicMock())
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(edit_bible_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -132,3 +132,19 @@ def test_update_slide_list(form):
# THEN: The slides should be created in correct order
form.slide_list_view.addItems.assert_called_with(['1st Slide', '2nd Slide', '3rd Slide'])
@patch.object(EditCustomForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: An edit custom slide form and a patched help function
main_window = QtWidgets.QMainWindow()
custom_form = EditCustomForm(MagicMock(), main_window, MagicMock())
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(custom_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -22,9 +22,9 @@
Package to test the openlp.plugins.songs.forms.editsongform package.
"""
import pytest
from unittest.mock import MagicMock
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets
from PyQt5 import QtWidgets, QtTest, QtCore
from openlp.core.common.i18n import UiStrings
from openlp.core.common.registry import Registry
@ -143,3 +143,21 @@ def test_verse_order_lowercase(form):
# THEN: The verse order should be converted to uppercase
assert form.verse_order_edit.text() == 'V1 V2 C1 V3 C1 V4 C1'
@patch.object(EditSongForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: An edit song form and a patched help function
main_window = QtWidgets.QMainWindow()
Registry().register('main_window', main_window)
Registry().register('theme_manager', MagicMock())
edit_song_form = EditSongForm(MagicMock(), main_window, MagicMock())
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(edit_song_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2021 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
Package to test the openlp.plugins.songusage.forms.songusagedeleteform package.
"""
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets, QtTest, QtCore
from openlp.plugins.songusage.forms.songusagedeleteform import SongUsageDeleteForm
@patch.object(SongUsageDeleteForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: A songusage delete form and a patched help function
main_window = QtWidgets.QMainWindow()
delete_form = SongUsageDeleteForm(MagicMock(), main_window)
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(delete_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()

View File

@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
##########################################################################
# OpenLP - Open Source Lyrics Projection #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2021 OpenLP Developers #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
Package to test the openlp.plugins.songusage.forms.songusagedetailform package.
"""
from unittest.mock import MagicMock, patch
from PyQt5 import QtWidgets, QtTest, QtCore
from openlp.plugins.songusage.forms.songusagedetailform import SongUsageDetailForm
@patch.object(SongUsageDetailForm, 'provide_help')
def test_help(mocked_help, settings):
"""
Test the help button
"""
# GIVEN: A songusage detail form and a patched help function
main_window = QtWidgets.QMainWindow()
detail_form = SongUsageDetailForm(MagicMock(), main_window)
# WHEN: The Help button is clicked
QtTest.QTest.mouseClick(detail_form.button_box.button(QtWidgets.QDialogButtonBox.Help), QtCore.Qt.LeftButton)
# THEN: The Help function should be called
mocked_help.assert_called_once()