From 3bca28fa0fd6de43b16ef22e517ca68382735a78 Mon Sep 17 00:00:00 2001 From: Gabriel Loo Date: Thu, 14 Apr 2016 04:18:53 -0400 Subject: [PATCH 1/2] fixed bug #1570228 'App crashes on SongSelect Importer search' Fixes: https://launchpad.net/bugs/1570228 --- openlp/plugins/songs/forms/songselectform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/songs/forms/songselectform.py b/openlp/plugins/songs/forms/songselectform.py index c5398fc0d..84ced5383 100755 --- a/openlp/plugins/songs/forms/songselectform.py +++ b/openlp/plugins/songs/forms/songselectform.py @@ -299,6 +299,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog): # Set up UI components self.view_button.setEnabled(False) self.search_button.setEnabled(False) + self.search_combobox.setEnabled(False) self.search_progress_bar.setMinimum(0) self.search_progress_bar.setMaximum(0) self.search_progress_bar.setValue(0) @@ -354,6 +355,7 @@ class SongSelectForm(QtWidgets.QDialog, Ui_SongSelectDialog): self.application.process_events() self.set_progress_visible(False) self.search_button.setEnabled(True) + self.search_combobox.setEnabled(True) self.application.process_events() def on_search_results_widget_selection_changed(self): From caa9c59c752c172f02fe0beb673b7e2267f8bf98 Mon Sep 17 00:00:00 2001 From: Gabriel Loo Date: Sun, 17 Apr 2016 18:55:40 -0400 Subject: [PATCH 2/2] Added unit tests for SongSelect Importer search --- .../openlp_plugins/songs/test_songselect.py | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index 5a94ee1ac..18ada0338 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -716,8 +716,43 @@ class TestSongSelectForm(TestCase, TestMixin): # WHEN: The stop button is clicked ssform.on_stop_button_clicked() - # THEN: The view button should be enabled + # THEN: The view button, search box and search button should be enabled mocked_song_select_importer.stop.assert_called_with() + self.assertTrue(ssform.search_button.isEnabled()) + self.assertTrue(ssform.search_combobox.isEnabled()) + + @patch('openlp.plugins.songs.forms.songselectform.Settings') + @patch('openlp.plugins.songs.forms.songselectform.QtCore.QThread') + @patch('openlp.plugins.songs.forms.songselectform.SearchWorker') + def on_search_button_clicked_test(self, MockedSearchWorker, MockedQtThread, MockedSettings): + """ + Test that search fields are disabled when search button is clicked. + """ + # GIVEN: A mocked SongSelect form + ssform = SongSelectForm(None, MagicMock(), MagicMock()) + ssform.initialise() + + # WHEN: The search button is clicked + ssform.on_search_button_clicked() + + # THEN: The search box and search button should be disabled + self.assertFalse(ssform.search_button.isEnabled()) + self.assertFalse(ssform.search_combobox.isEnabled()) + + def on_search_finished_test(self): + """ + Test that search fields are enabled when search is finished. + """ + # GIVEN: A mocked SongSelect form + ssform = SongSelectForm(None, MagicMock(), MagicMock()) + ssform.initialise() + + # WHEN: The search is finished + ssform.on_search_finished() + + # THEN: The search box and search button should be enabled + self.assertTrue(ssform.search_button.isEnabled()) + self.assertTrue(ssform.search_combobox.isEnabled()) class TestSongSelectFileImport(SongImportTestHelper):