From 6d243557f5e9129037198a2445da5c986123ed82 Mon Sep 17 00:00:00 2001 From: Kyle Nweeia Date: Wed, 31 Oct 2018 21:25:43 -0400 Subject: [PATCH 1/4] fixed bug #1678632 'SongSelect Importer Infinite Loop' --- openlp/plugins/songs/lib/songselect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/lib/songselect.py b/openlp/plugins/songs/lib/songselect.py index 35f01888b..50fbb8107 100644 --- a/openlp/plugins/songs/lib/songselect.py +++ b/openlp/plugins/songs/lib/songselect.py @@ -171,6 +171,7 @@ class SongSelectImport(object): callback(song) songs.append(song) if len(songs) >= max_results: + self.run_search = False break current_page += 1 return songs From d086e83656f0c0e11c2743b3a790340516e21ed0 Mon Sep 17 00:00:00 2001 From: Kyle Nweeia Date: Tue, 11 Dec 2018 21:30:22 -0500 Subject: [PATCH 2/4] --- openlp/plugins/songs/lib/songselect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openlp/plugins/songs/lib/songselect.py b/openlp/plugins/songs/lib/songselect.py index 35f01888b..50fbb8107 100644 --- a/openlp/plugins/songs/lib/songselect.py +++ b/openlp/plugins/songs/lib/songselect.py @@ -171,6 +171,7 @@ class SongSelectImport(object): callback(song) songs.append(song) if len(songs) >= max_results: + self.run_search = False break current_page += 1 return songs From ea14f6cea8f344f0d671d00a51e4b4d58f49b9d3 Mon Sep 17 00:00:00 2001 From: Kyle Nweeia Date: Thu, 13 Dec 2018 20:27:59 -0500 Subject: [PATCH 3/4] --- tests/functional/openlp_plugins/songs/test_songselect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index aa55fca20..50c3a43f6 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -285,9 +285,9 @@ class TestSongSelectImport(TestCase, TestMixin): # WHEN: The search method is called results = importer.search('text', 2, mock_callback) - # THEN: callback was called twice, open was called twice, find_all was called twice, max results returned + # THEN: callback was called twice, open was called once, find_all was called twice, max results returned assert 2 == mock_callback.call_count, 'callback should have been called twice' - assert 2 == mocked_opener.open.call_count, 'open should have been called twice' + assert 1 == mocked_opener.open.call_count, 'open should have been called once' assert 2 == mocked_results_page.find_all.call_count, 'find_all should have been called twice' mocked_results_page.find_all.assert_called_with('div', 'song-result') expected_list = [{'title': 'Title 1', 'authors': ['James', 'John'], 'link': BASE_URL + '/url1'}, From 98bc575ba2483e432d6b07aac4d901a925e22817 Mon Sep 17 00:00:00 2001 From: Kyle Nweeia Date: Thu, 13 Dec 2018 20:46:55 -0500 Subject: [PATCH 4/4] --- tests/functional/openlp_plugins/songs/test_songselect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/openlp_plugins/songs/test_songselect.py b/tests/functional/openlp_plugins/songs/test_songselect.py index 50c3a43f6..69f0326d9 100644 --- a/tests/functional/openlp_plugins/songs/test_songselect.py +++ b/tests/functional/openlp_plugins/songs/test_songselect.py @@ -285,10 +285,10 @@ class TestSongSelectImport(TestCase, TestMixin): # WHEN: The search method is called results = importer.search('text', 2, mock_callback) - # THEN: callback was called twice, open was called once, find_all was called twice, max results returned + # THEN: callback was called twice, open was called once, find_all was called once, max results returned assert 2 == mock_callback.call_count, 'callback should have been called twice' assert 1 == mocked_opener.open.call_count, 'open should have been called once' - assert 2 == mocked_results_page.find_all.call_count, 'find_all should have been called twice' + assert 1 == mocked_results_page.find_all.call_count, 'find_all should have been called once' mocked_results_page.find_all.assert_called_with('div', 'song-result') expected_list = [{'title': 'Title 1', 'authors': ['James', 'John'], 'link': BASE_URL + '/url1'}, {'title': 'Title 2', 'authors': ['Philip'], 'link': BASE_URL + '/url2'}]