From a409306d0d359478897cd429269a58303638edc0 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Sat, 30 Jan 2016 09:33:31 +0100 Subject: [PATCH 1/2] Fix bug 1537212 Fixes: https://launchpad.net/bugs/1537212 --- openlp/plugins/songs/forms/editsongform.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 4bc77c65c..cfe6c29a5 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -324,7 +324,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): if self.topics_combo_box.hasFocus() and self.topics_combo_box.currentText(): self.on_topic_add_button_clicked() return - if self.songbooks_combo_box.hasFocus() and self.songbooks_combo_box.currentText(): + if self.songbooks_combo_box.hasFocus() or self.songbook_entry_edit.hasFocus(): self.on_songbook_add_button_clicked() return QtWidgets.QDialog.keyPressEvent(self, event) @@ -514,6 +514,7 @@ class EditSongForm(QtWidgets.QDialog, Ui_EditSongDialog, RegistryProperties): topic_name.setData(QtCore.Qt.UserRole, topic.id) self.topics_list_view.addItem(topic_name) self.songbooks_list_view.clear() + self.songbook_entry_edit.clear() for songbook_entry in self.song.songbook_entries: self.add_songbook_entry_to_list(songbook_entry.songbook.id, songbook_entry.songbook.name, songbook_entry.entry) From 0f1c7bae4441ddaf3f0e8a31e5342c6bbc2e78a6 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Sat, 30 Jan 2016 15:13:35 +0100 Subject: [PATCH 2/2] Add test --- .../songs/test_openlyricsimport.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py index 02910a1f2..71d3a2ba5 100644 --- a/tests/functional/openlp_plugins/songs/test_openlyricsimport.py +++ b/tests/functional/openlp_plugins/songs/test_openlyricsimport.py @@ -74,6 +74,13 @@ author_xml = '\ \ ' +songbook_xml = '\ + \ + \ + \ + \ + ' + class TestOpenLyricsImport(TestCase, TestMixin): """ @@ -166,3 +173,22 @@ class TestOpenLyricsImport(TestCase, TestMixin): # THEN: add_author should have been called twice self.assertEquals(mocked_song.method_calls[0][1][1], 'words+music') self.assertEquals(mocked_song.method_calls[1][1][1], 'words') + + def process_songbooks_test(self): + """ + Test that _process_songbooks works + """ + # GIVEN: A OpenLyric XML with songbooks and a mocked out manager + with patch('openlp.plugins.songs.lib.openlyricsxml.Book'): + mocked_manager = MagicMock() + mocked_manager.get_object_filtered.return_value = None + ol = OpenLyrics(mocked_manager) + properties_xml = objectify.fromstring(songbook_xml) + mocked_song = MagicMock() + + # WHEN: processing the songbook xml + ol._process_songbooks(properties_xml, mocked_song) + + # THEN: add_songbook_entry should have been called twice + self.assertEquals(mocked_song.method_calls[0][1][1], '48') + self.assertEquals(mocked_song.method_calls[1][1][1], '445 A')