From 6d0e006b09feac02e1e85c70fe68aff7a8741433 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 14:03:29 +0100 Subject: [PATCH 1/8] Change Combobox to Checkbox for plugin states --- openlp/core/ui/plugindialog.py | 10 ++++------ openlp/core/ui/pluginform.py | 19 ++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 5d36dd72c..273d20383 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -53,10 +53,9 @@ class Ui_PluginViewDialog(object): self.plugin_info_layout.setObjectName('plugin_info_layout') self.status_label = QtWidgets.QLabel(self.plugin_info_group_box) self.status_label.setObjectName('status_label') - self.status_combo_box = QtWidgets.QComboBox(self.plugin_info_group_box) - self.status_combo_box.addItems(('', '')) - self.status_combo_box.setObjectName('status_combo_box') - self.plugin_info_layout.addRow(self.status_label, self.status_combo_box) + self.status_checkbox = QtWidgets.QCheckBox(self.plugin_info_group_box) + self.status_checkbox.setObjectName('status_checkbox') + self.plugin_info_layout.addRow(self.status_label, self.status_checkbox) self.version_label = QtWidgets.QLabel(self.plugin_info_group_box) self.version_label.setObjectName('version_label') self.version_number_label = QtWidgets.QLabel(self.plugin_info_group_box) @@ -83,5 +82,4 @@ class Ui_PluginViewDialog(object): self.version_label.setText('%s:' % UiStrings().Version) self.about_label.setText('%s:' % UiStrings().About) self.status_label.setText(translate('OpenLP.PluginForm', 'Status:')) - self.status_combo_box.setItemText(0, translate('OpenLP.PluginForm', 'Active')) - self.status_combo_box.setItemText(1, translate('OpenLP.PluginForm', 'Inactive')) + self.status_checkbox.setText(translate('OpenLP.PluginForm', 'Active')) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 7d71e8ff4..040e9f3a1 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -49,7 +49,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self._clear_details() # Right, now let's put some signals and slots together! self.plugin_list_widget.itemSelectionChanged.connect(self.on_plugin_list_widget_selection_changed) - self.status_combo_box.currentIndexChanged.connect(self.on_status_combo_box_changed) + self.status_checkbox.stateChanged.connect(self.on_status_checkbox_changed) def load(self): """ @@ -86,10 +86,10 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ Clear the plugin details widgets """ - self.status_combo_box.setCurrentIndex(-1) + self.status_checkbox.setChecked(False) self.version_number_label.setText('') self.about_text_browser.setHtml('') - self.status_combo_box.setEnabled(False) + self.status_checkbox.setEnabled(False) def _set_details(self): """ @@ -99,11 +99,8 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self.version_number_label.setText(self.active_plugin.version) self.about_text_browser.setHtml(self.active_plugin.about()) self.programatic_change = True - status = PluginStatus.Active - if self.active_plugin.status == PluginStatus.Active: - status = PluginStatus.Inactive - self.status_combo_box.setCurrentIndex(status) - self.status_combo_box.setEnabled(True) + self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active) + self.status_checkbox.setEnabled(True) self.programatic_change = False def on_plugin_list_widget_selection_changed(self): @@ -125,13 +122,13 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): else: self._clear_details() - def on_status_combo_box_changed(self, status): + def on_status_checkbox_changed(self, status): """ If the status of a plugin is altered, apply the change """ - if self.programatic_change or status == PluginStatus.Disabled: + if self.programatic_change: return - if status == PluginStatus.Inactive: + if status: self.application.set_busy_cursor() self.active_plugin.toggle_status(PluginStatus.Active) self.application.set_normal_cursor() From ed0b739d97c153820a83323ecfc80b9259abebd9 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 15:00:23 +0100 Subject: [PATCH 2/8] Add .coveragerc --- .bzrignore | 1 + .coveragerc | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 .coveragerc diff --git a/.bzrignore b/.bzrignore index 272c37e88..68fa826de 100644 --- a/.bzrignore +++ b/.bzrignore @@ -43,3 +43,4 @@ __pycache__ .coverage cover *.kdev4 +coverage diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..f8f529f44 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[run] +source = openlp + +[html] +directory = coverage From 480a2d8512bf17d2088e500bac951a535681b2fb Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Sun, 3 Jan 2016 15:50:41 +0100 Subject: [PATCH 3/8] Make about() method of SongUsagePlugin static and add a test for it --- openlp/plugins/songusage/songusageplugin.py | 5 +-- .../openlp_plugins/songusage/__init__.py | 24 ++++++++++++++ .../songusage/test_songusage.py | 31 +++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/functional/openlp_plugins/songusage/__init__.py create mode 100644 tests/functional/openlp_plugins/songusage/test_songusage.py diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 0bf8ed9a5..b433d96e0 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -226,8 +226,9 @@ class SongUsagePlugin(Plugin): """ self.song_usage_detail_form.initialise() self.song_usage_detail_form.exec() - - def about(self): + + @staticmethod + def about(): """ The plugin about text diff --git a/tests/functional/openlp_plugins/songusage/__init__.py b/tests/functional/openlp_plugins/songusage/__init__.py new file mode 100644 index 000000000..917bf47cd --- /dev/null +++ b/tests/functional/openlp_plugins/songusage/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 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 # +############################################################################### +""" +Tests for the Songusage plugin +""" diff --git a/tests/functional/openlp_plugins/songusage/test_songusage.py b/tests/functional/openlp_plugins/songusage/test_songusage.py new file mode 100644 index 000000000..7b940bc20 --- /dev/null +++ b/tests/functional/openlp_plugins/songusage/test_songusage.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2016 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 Songusage plugin. +""" +from unittest import TestCase +from openlp.plugins.songusage.songusageplugin import SongUsagePlugin + +class TestSongUsage(TestCase): + + def test_about_text(self): + self.assertNotEquals(len(SongUsagePlugin.about()), 0) From 9ced5436bae39514014661b3545d4f8469fec0a8 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 22 Feb 2016 15:34:00 +0100 Subject: [PATCH 4/8] Fix exception caused when plugins are disabled --- openlp/core/ui/pluginform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d7bd1d1d6..d67e7ea1e 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -126,7 +126,7 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): """ If the status of a plugin is altered, apply the change """ - if self.programatic_change: + if self.programatic_change or self.active_plugin is None: return if status: self.application.set_busy_cursor() From 9356d990acf5f061cc7ae198e8c6eb80e6e34ad0 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 22 Feb 2016 15:51:11 +0100 Subject: [PATCH 5/8] Show plugin information even if the plugin is disabled --- openlp/core/ui/pluginform.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index d67e7ea1e..f43757b44 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -99,8 +99,12 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): self.version_number_label.setText(self.active_plugin.version) self.about_text_browser.setHtml(self.active_plugin.about()) self.programatic_change = True - self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active) - self.status_checkbox.setEnabled(True) + if self.active_plugin.status != PluginStatus.Disabled: + self.status_checkbox.setChecked(self.active_plugin.status == PluginStatus.Active) + self.status_checkbox.setEnabled(True) + else: + self.status_checkbox.setChecked(False) + self.status_checkbox.setEnabled(False) self.programatic_change = False def on_plugin_list_widget_selection_changed(self): @@ -113,10 +117,9 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): plugin_name_singular = self.plugin_list_widget.currentItem().text().split('(')[0][:-1] self.active_plugin = None for plugin in self.plugin_manager.plugins: - if plugin.status != PluginStatus.Disabled: - if plugin.name_strings['singular'] == plugin_name_singular: - self.active_plugin = plugin - break + if plugin.name_strings['singular'] == plugin_name_singular: + self.active_plugin = plugin + break if self.active_plugin: self._set_details() else: From 1d51939308070471702d7e745dae028b009bf77e Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Mon, 22 Feb 2016 15:51:58 +0100 Subject: [PATCH 6/8] Do not show version numbers for plugins --- openlp/core/ui/plugindialog.py | 6 ------ openlp/core/ui/pluginform.py | 2 -- 2 files changed, 8 deletions(-) diff --git a/openlp/core/ui/plugindialog.py b/openlp/core/ui/plugindialog.py index 273d20383..583728fcd 100644 --- a/openlp/core/ui/plugindialog.py +++ b/openlp/core/ui/plugindialog.py @@ -56,11 +56,6 @@ class Ui_PluginViewDialog(object): self.status_checkbox = QtWidgets.QCheckBox(self.plugin_info_group_box) self.status_checkbox.setObjectName('status_checkbox') self.plugin_info_layout.addRow(self.status_label, self.status_checkbox) - self.version_label = QtWidgets.QLabel(self.plugin_info_group_box) - self.version_label.setObjectName('version_label') - self.version_number_label = QtWidgets.QLabel(self.plugin_info_group_box) - self.version_number_label.setObjectName('version_number_label') - self.plugin_info_layout.addRow(self.version_label, self.version_number_label) self.about_label = QtWidgets.QLabel(self.plugin_info_group_box) self.about_label.setObjectName('about_label') self.about_text_browser = QtWidgets.QTextBrowser(self.plugin_info_group_box) @@ -79,7 +74,6 @@ class Ui_PluginViewDialog(object): """ plugin_view_dialog.setWindowTitle(translate('OpenLP.PluginForm', 'Manage Plugins')) self.plugin_info_group_box.setTitle(translate('OpenLP.PluginForm', 'Plugin Details')) - self.version_label.setText('%s:' % UiStrings().Version) self.about_label.setText('%s:' % UiStrings().About) self.status_label.setText(translate('OpenLP.PluginForm', 'Status:')) self.status_checkbox.setText(translate('OpenLP.PluginForm', 'Active')) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index f43757b44..cb6dd70aa 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -87,7 +87,6 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): Clear the plugin details widgets """ self.status_checkbox.setChecked(False) - self.version_number_label.setText('') self.about_text_browser.setHtml('') self.status_checkbox.setEnabled(False) @@ -96,7 +95,6 @@ class PluginForm(QtWidgets.QDialog, Ui_PluginViewDialog, RegistryProperties): Set the details of the currently selected plugin """ log.debug('PluginStatus: %s', str(self.active_plugin.status)) - self.version_number_label.setText(self.active_plugin.version) self.about_text_browser.setHtml(self.active_plugin.about()) self.programatic_change = True if self.active_plugin.status != PluginStatus.Disabled: From 6bbf783a2e582d449366971a8c0e7b94d0744758 Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Tue, 17 May 2016 21:31:56 +0200 Subject: [PATCH 7/8] Add test --- tests/functional/openlp_core_common/test_actions.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/functional/openlp_core_common/test_actions.py b/tests/functional/openlp_core_common/test_actions.py index 2b2d735bb..a2f57e969 100644 --- a/tests/functional/openlp_core_common/test_actions.py +++ b/tests/functional/openlp_core_common/test_actions.py @@ -111,6 +111,17 @@ class TestCategoryActionList(TestCase): self.assertEqual(self.list.actions[0], (41, self.action2)) self.assertEqual(self.list.actions[1], (42, self.action1)) + def iterator_test(self): + """ + Test the __iter__ and __next__ methods + """ + self.list.add(self.action1) + self.list.add(self.action2) + + l = [a for a in self.list] + self.assertIs(l[0], self.action1) + self.assertIs(l[1], self.action2) + def remove_test(self): """ Test the remove() method From f3e1194956d4084498359693680a5dd8ac9c0bfb Mon Sep 17 00:00:00 2001 From: Simon Hanna Date: Tue, 17 May 2016 21:35:25 +0200 Subject: [PATCH 8/8] Add comments to test --- tests/functional/openlp_core_common/test_actions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_core_common/test_actions.py b/tests/functional/openlp_core_common/test_actions.py index a2f57e969..92f030df2 100644 --- a/tests/functional/openlp_core_common/test_actions.py +++ b/tests/functional/openlp_core_common/test_actions.py @@ -115,10 +115,14 @@ class TestCategoryActionList(TestCase): """ Test the __iter__ and __next__ methods """ + # GIVEN: The list including two actions self.list.add(self.action1) self.list.add(self.action2) - + + # WHEN: Iterating over the list l = [a for a in self.list] + # THEN: Make sure they are returned in correct order + self.assertEquals(len(self.list), 2) self.assertIs(l[0], self.action1) self.assertIs(l[1], self.action2)