openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #20811
[Merge] lp:~googol/openlp/bug-1170435 into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/bug-1170435 into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Related bugs:
Bug #1170435 in OpenLP: "We should not warn when verse order is empty"
https://bugs.launchpad.net/openlp/+bug/1170435
For more details, see:
https://code.launchpad.net/~googol/openlp/bug-1170435/+merge/170772
Hello,
- fixes bug #1170435 (We should not warn when verse order is empty)
--
https://code.launchpad.net/~googol/openlp/bug-1170435/+merge/170772
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2013-03-08 08:14:39 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2013-06-21 10:18:28 +0000
@@ -275,7 +275,6 @@
self.bottom_layout.setObjectName(u'bottom_layout')
self.warning_label = QtGui.QLabel(edit_song_dialog)
self.warning_label.setObjectName(u'warning_label')
- self.warning_label.setVisible(False)
self.bottom_layout.addWidget(self.warning_label)
self.button_box = create_button_box(edit_song_dialog, u'button_box', [u'cancel', u'save'])
self.bottom_layout.addWidget(self.button_box)
@@ -323,8 +322,10 @@
self.from_media_button.setText(translate('SongsPlugin.EditSongForm', 'Add &Media'))
self.audio_remove_button.setText(translate('SongsPlugin.EditSongForm', '&Remove'))
self.audio_remove_all_button.setText(translate('SongsPlugin.EditSongForm', 'Remove &All'))
- self.warning_label.setText(
- translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong> Not all of the verses are in use.'))
+ self.not_all_verses_used_warning = \
+ translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong> Not all of the verses are in use.')
+ self.no_verse_order_entered_warning = \
+ translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong> You have not entered a verse order.')
def create_combo_box(parent, name):
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2013-04-20 20:34:46 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2013-06-21 10:18:28 +0000
@@ -456,6 +456,8 @@
self.title_edit.setFocus()
# Hide or show the preview button.
self.preview_button.setVisible(preview)
+ # Check if all verse tags are used.
+ self.on_verse_order_text_changed(self.verse_order_edit.text())
def tag_rows(self):
"""
@@ -683,21 +685,34 @@
self.verse_edit_button.setEnabled(False)
self.verse_delete_button.setEnabled(False)
+
def on_verse_order_text_changed(self, text):
- verses = []
- verse_names = []
- order = self._extract_verse_order(text)
+ """
+ Checks if the verse order is complete or missing. Shows a error message according to the state of the verse
+ order.
+
+ ``text``
+ The text of the verse order edit (ignored).
+ """
+ # 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.
+ verses_not_used = []
for index in range(self.verse_list_widget.rowCount()):
verse = self.verse_list_widget.item(index, 0)
verse = verse.data(QtCore.Qt.UserRole)
- if verse not in verse_names:
- verses.append(verse)
- verse_names.append(u'%s%s' % (VerseType.translated_tag(verse[0]), verse[1:]))
- verses_not_used = []
- for verse in verses:
- if not verse in order:
+ print(verse)
+ if verse not in verses_in_order:
verses_not_used.append(verse)
- self.warning_label.setVisible(len(verses_not_used) > 0)
+ # Set the label text.
+ label_text = u''
+ # No verse order was entered.
+ if not verses_in_order:
+ label_text = self.no_verse_order_entered_warning
+ # The verse order does not contain all verses.
+ elif verses_not_used:
+ label_text = self.not_all_verses_used_warning
+ self.warning_label.setText(label_text)
def on_copyright_insert_button_triggered(self):
text = self.copyright_edit.text()
=== modified file 'tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py'
--- tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py 2013-03-29 06:25:01 +0000
+++ tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py 2013-06-21 10:18:28 +0000
@@ -44,4 +44,68 @@
self.assertFalse(self.form.topic_remove_button.isEnabled(), u'The topic remove button should not be enabled')
def is_verse_edit_form_executed_test(self):
- pass
\ No newline at end of file
+ pass
+
+ def verse_order_no_warning_test(self):
+ """
+ Test if the verse order warning is not shown
+ """
+ # GIVEN: Mocked methods.
+ given_verse_order = u'V1 V2'
+ self.form.verse_list_widget.rowCount = MagicMock(return_value=2)
+ # Mock out the verse.
+ first_verse = MagicMock()
+ first_verse.data = MagicMock(return_value=u'V1')
+ second_verse = MagicMock()
+ second_verse.data = MagicMock(return_value= u'V2')
+ self.form.verse_list_widget.item = MagicMock(side_effect=[first_verse, second_verse])
+ self.form._extract_verse_order = MagicMock(return_value=given_verse_order.split())
+
+ # WHEN: Call the method.
+ self.form.on_verse_order_text_changed(given_verse_order)
+
+ # THEN: The warning lable should be hidden.
+ print self.form.warning_label.text()
+ assert self.form.warning_label.text() == u'', u'There should be no warning.'
+
+ def verse_order_incomplete_warning_test(self):
+ """
+ Test if the verse-order-incomple warning is shown
+ """
+ # GIVEN: Mocked methods.
+ given_verse_order = u'V1'
+ self.form.verse_list_widget.rowCount = MagicMock(return_value=2)
+ # Mock out the verse.
+ first_verse = MagicMock()
+ first_verse.data = MagicMock(return_value=u'V1')
+ second_verse = MagicMock()
+ second_verse.data = MagicMock(return_value= u'V2')
+ self.form.verse_list_widget.item = MagicMock(side_effect=[first_verse, second_verse])
+ self.form._extract_verse_order = MagicMock(return_value=[given_verse_order])
+
+ # WHEN: Call the method.
+ self.form.on_verse_order_text_changed(given_verse_order)
+
+ # THEN: The warning lable should be hidden.
+ assert self.form.warning_label.text() == u'<strong>Warning:</strong> Not all of the verses are in use.', \
+ u'The verse-order-incomplete warning should be shown.'
+
+ def bug_1170435_test(self):
+ """
+ Regression test for bug 1170435 (test if "no verse order" message is shown)
+ """
+ # GIVEN: Mocked methods.
+ given_verse_order = u''
+ self.form.verse_list_widget.rowCount = MagicMock(return_value=1)
+ # Mock out the verse. (We want a verse type to be returned).
+ mocked_verse = MagicMock()
+ mocked_verse.data = MagicMock(return_value=u'V1')
+ self.form.verse_list_widget.item = MagicMock(return_value=mocked_verse)
+ self.form._extract_verse_order = MagicMock(return_value=[given_verse_order])
+ self.form.verse_order_edit.text = MagicMock(return_value=given_verse_order)
+ # WHEN: Call the method.
+ self.form.on_verse_order_text_changed(given_verse_order)
+
+ # THEN: The warning lable should be hidden.
+ assert self.form.warning_label.text() == u'<strong>Warning:</strong> You have not entered a verse order.', \
+ u'The no-verse-order message should be shown.'
Follow ups