Merge lp:~phill-ridout/openlp/test-fixes into lp:openlp

Proposed by Phill
Status: Superseded
Proposed branch: lp:~phill-ridout/openlp/test-fixes
Merge into: lp:openlp
Diff against target: 292 lines (+84/-55)
5 files modified
tests/functional/openlp_core_lib/test_renderer.py (+3/-1)
tests/functional/openlp_plugins/bibles/test_mediaitem.py (+78/-53)
tests/interfaces/openlp_core_ui/test_projectoreditform.py (+1/-1)
tests/interfaces/openlp_plugins/bibles/test_lib_manager.py (+1/-0)
tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py (+1/-0)
To merge this branch: bzr merge lp:~phill-ridout/openlp/test-fixes
Reviewer Review Type Date Requested Status
Raoul Snyman Pending
Review via email: mp+325038@code.launchpad.net

This proposal has been superseded by a proposal from 2017-06-03.

Description of the change

Fixed some bible media item tests and one render test. The 02-Functional tests now pass, but we get a seg fault on the interface-tests

[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2053/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1963/
[FAILURE] https://ci.openlp.io/job/Branch-03-Interface-Tests/1887/
Stopping after failure

To post a comment you must log in.
lp:~phill-ridout/openlp/test-fixes updated
2748. By Phill

fixed some seg faults

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/functional/openlp_core_lib/test_renderer.py'
--- tests/functional/openlp_core_lib/test_renderer.py 2017-05-23 05:00:42 +0000
+++ tests/functional/openlp_core_lib/test_renderer.py 2017-06-03 23:27:29 +0000
@@ -182,13 +182,15 @@
182 @patch('openlp.core.lib.renderer.QtWebKitWidgets.QWebView')182 @patch('openlp.core.lib.renderer.QtWebKitWidgets.QWebView')
183 @patch('openlp.core.lib.renderer.build_lyrics_format_css')183 @patch('openlp.core.lib.renderer.build_lyrics_format_css')
184 @patch('openlp.core.lib.renderer.build_lyrics_outline_css')184 @patch('openlp.core.lib.renderer.build_lyrics_outline_css')
185 def test_set_text_rectangle(self, mock_outline_css, mock_lyrics_css, mock_webview):185 @patch('openlp.core.lib.renderer.build_chords_css')
186 def test_set_text_rectangle(self, mock_build_chords_css, mock_outline_css, mock_lyrics_css, mock_webview):
186 """187 """
187 Test set_text_rectangle returns a proper html string188 Test set_text_rectangle returns a proper html string
188 """189 """
189 # GIVEN: test object and data190 # GIVEN: test object and data
190 mock_lyrics_css.return_value = ' FORMAT CSS; '191 mock_lyrics_css.return_value = ' FORMAT CSS; '
191 mock_outline_css.return_value = ' OUTLINE CSS; '192 mock_outline_css.return_value = ' OUTLINE CSS; '
193 mock_build_chords_css.return_value = ' CHORDS CSS; '
192 theme_data = Theme()194 theme_data = Theme()
193 theme_data.font_main_name = 'Arial'195 theme_data.font_main_name = 'Arial'
194 theme_data.font_main_size = 20196 theme_data.font_main_size = 20
195197
=== modified file 'tests/functional/openlp_plugins/bibles/test_mediaitem.py'
--- tests/functional/openlp_plugins/bibles/test_mediaitem.py 2017-04-03 20:28:16 +0000
+++ tests/functional/openlp_plugins/bibles/test_mediaitem.py 2017-06-03 23:27:29 +0000
@@ -31,7 +31,7 @@
3131
32from openlp.core.common import Registry32from openlp.core.common import Registry
33from openlp.core.lib import MediaManagerItem33from openlp.core.lib import MediaManagerItem
34from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch, ResultsTab, SearchStatus, \34from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch, ResultsTab, SearchStatus, SearchTabs, \
35 get_reference_separators, VALID_TEXT_SEARCH35 get_reference_separators, VALID_TEXT_SEARCH
3636
3737
@@ -206,29 +206,63 @@
206 """206 """
207 Test the correct widget gets focus when the BibleMediaItem receives focus207 Test the correct widget gets focus when the BibleMediaItem receives focus
208 """208 """
209 # GIVEN: An instance of :class:`MediaManagerItem` and a mocked out search_tab and search_edit209 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
210 self.media_item.search_tab = MagicMock(**{'isVisible.return_value': True})210 self.media_item.search_tab = MagicMock(**{'isVisible.return_value': True})
211 self.media_item.search_edit = MagicMock()211 self.media_item.search_edit = MagicMock()
212212 self.media_item.select_tab = MagicMock(**{'isVisible.return_value': False})
213 # WHEN: Calling on_focus213 self.media_item.select_book_combo_box = MagicMock()
214 self.media_item.on_focus()214 self.media_item.options_tab = MagicMock(**{'isVisible.return_value': False})
215215 self.media_item.version_combo_box = MagicMock()
216 # THEN: setFocus and selectAll should have been called on search_edit216
217 self.assertEqual(self.media_item.search_edit.mock_calls, [call.setFocus(), call.selectAll()])217 # WHEN: Calling on_focus
218218 self.media_item.on_focus()
219 def test_on_focus_search_tab_not_visible(self):219
220 """220 # THEN: search_edit should now have focus and its text selected
221 Test the correct widget gets focus when the BibleMediaItem receives focus221 self.media_item.search_edit.assert_has_calls([call.setFocus(), call.selectAll()])
222 """222 self.media_item.select_book_combo_box.assert_not_called()
223 # GIVEN: An instance of :class:`MediaManagerItem` and a mocked out search_tab and select_book_combo_box223 self.media_item.version_combo_box.setFocus.assert_not_called()
224 self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})224
225 self.media_item.select_book_combo_box = MagicMock()225 def test_on_focus_select_tab_visible(self):
226226 """
227 # WHEN: Calling on_focus227 Test the correct widget gets focus when the BibleMediaItem receives focus
228 self.media_item.on_focus()228 """
229229 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
230 # THEN: setFocus should have been called on select_book_combo_box230 self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
231 self.assertTrue(self.media_item.select_book_combo_box.setFocus.called)231 self.media_item.search_edit = MagicMock()
232 self.media_item.select_tab = MagicMock(**{'isVisible.return_value': True})
233 self.media_item.select_book_combo_box = MagicMock()
234 self.media_item.options_tab = MagicMock(**{'isVisible.return_value': False})
235 self.media_item.version_combo_box = MagicMock()
236
237 # WHEN: Calling on_focus
238 self.media_item.on_focus()
239
240 # THEN: select_book_combo_box should have focus
241 self.media_item.search_edit.setFocus.assert_not_called()
242 self.media_item.search_edit.selectAll.assert_not_called()
243 self.media_item.select_book_combo_box.setFocus.assert_called_once_with()
244 self.media_item.version_combo_box.setFocus.assert_not_called()
245
246 def test_on_focus_options_tab_visible(self):
247 """
248 Test the correct widget gets focus when the BibleMediaItem receives focus
249 """
250 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
251 self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
252 self.media_item.search_edit = MagicMock()
253 self.media_item.select_tab = MagicMock(**{'isVisible.return_value': False})
254 self.media_item.select_book_combo_box = MagicMock()
255 self.media_item.options_tab = MagicMock(**{'isVisible.return_value': True})
256 self.media_item.version_combo_box = MagicMock()
257
258 # WHEN: Calling on_focus
259 self.media_item.on_focus()
260
261 # THEN: version_combo_box have received focus
262 self.media_item.search_edit.setFocus.assert_not_called()
263 self.media_item.search_edit.selectAll.assert_not_called()
264 self.media_item.select_book_combo_box.setFocus.assert_not_called()
265 self.media_item.version_combo_box.setFocus.assert_called_once_with()
232266
233 def test_config_update_show_second_bible(self):267 def test_config_update_show_second_bible(self):
234 """268 """
@@ -611,12 +645,15 @@
611 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab645 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab
612 self.media_item.search_tab = MagicMock()646 self.media_item.search_tab = MagicMock()
613 self.media_item.select_tab = MagicMock()647 self.media_item.select_tab = MagicMock()
648 self.media_item.options_tab = MagicMock()
649 self.media_item.search_button = MagicMock()
614 with patch.object(self.media_item, 'on_focus'):650 with patch.object(self.media_item, 'on_focus'):
615651
616 # WHEN: The search_tab has been selected652 # WHEN: The search_tab has been selected
617 self.media_item.on_search_tab_bar_current_changed(0)653 self.media_item.on_search_tab_bar_current_changed(SearchTabs.Search)
618654
619 # THEN: search_tab should be setVisible and select_tab should be hidder655 # THEN: The search_button should be enabled, search_tab should be setVisible and select_tab should be hidden
656 self.media_item.search_button.setEnabled.assert_called_once_with(True)
620 self.media_item.search_tab.setVisible.assert_called_once_with(True)657 self.media_item.search_tab.setVisible.assert_called_once_with(True)
621 self.media_item.select_tab.setVisible.assert_called_once_with(False)658 self.media_item.select_tab.setVisible.assert_called_once_with(False)
622659
@@ -627,12 +664,15 @@
627 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab664 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab
628 self.media_item.search_tab = MagicMock()665 self.media_item.search_tab = MagicMock()
629 self.media_item.select_tab = MagicMock()666 self.media_item.select_tab = MagicMock()
667 self.media_item.options_tab = MagicMock()
668 self.media_item.search_button = MagicMock()
630 with patch.object(self.media_item, 'on_focus'):669 with patch.object(self.media_item, 'on_focus'):
631670
632 # WHEN: The select_tab has been selected671 # WHEN: The select_tab has been selected
633 self.media_item.on_search_tab_bar_current_changed(1)672 self.media_item.on_search_tab_bar_current_changed(SearchTabs.Select)
634673
635 # THEN: search_tab should be setVisible and select_tab should be hidder674 # THEN: The search_button should be enabled, select_tab should be setVisible and search_tab should be hidden
675 self.media_item.search_button.setEnabled.assert_called_once_with(True)
636 self.media_item.search_tab.setVisible.assert_called_once_with(False)676 self.media_item.search_tab.setVisible.assert_called_once_with(False)
637 self.media_item.select_tab.setVisible.assert_called_once_with(True)677 self.media_item.select_tab.setVisible.assert_called_once_with(True)
638678
@@ -660,44 +700,23 @@
660 # THEN: The select_book_combo_box model sort should have been reset700 # THEN: The select_book_combo_box model sort should have been reset
661 self.media_item.select_book_combo_box.model().sort.assert_called_once_with(-1)701 self.media_item.select_book_combo_box.model().sort.assert_called_once_with(-1)
662702
663 def test_on_clear_button_clicked_saved_tab(self):703 def test_on_clear_button_clicked(self):
664 """
665 Test on_clear_button_clicked when the saved tab is selected
666 """
667 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out saved_tab and select_tab and a mocked out
668 # list_view and search_edit
669 self.media_item.list_view = MagicMock()
670 self.media_item.search_edit = MagicMock()
671 self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Saved})
672 self.media_item.saved_results = ['Some', 'Results']
673 with patch.object(self.media_item, 'on_focus'):
674
675 # WHEN: Calling on_clear_button_clicked
676 self.media_item.on_clear_button_clicked()
677
678 # THEN: The list_view should be cleared
679 self.assertEqual(self.media_item.saved_results, [])
680 self.media_item.list_view.clear.assert_called_once_with()
681
682 def test_on_clear_button_clicked_search_tab(self):
683 """704 """
684 Test on_clear_button_clicked when the search tab is selected705 Test on_clear_button_clicked when the search tab is selected
685 """706 """
686 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab and a mocked out707 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab and a mocked out
687 # list_view and search_edit708 # list_view and search_edit
688 self.media_item.list_view = MagicMock()709 self.media_item.list_view = MagicMock(**{'selectedItems.return_value': ['Some', 'Results']})
689 self.media_item.search_edit = MagicMock()
690 self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Search})710 self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Search})
691 self.media_item.current_results = ['Some', 'Results']711 with patch.object(self.media_item, 'on_results_view_tab_total_update'):
692 with patch.object(self.media_item, 'on_focus'):
693712
694 # WHEN: Calling on_clear_button_clicked713 # WHEN: Calling on_clear_button_clicked
695 self.media_item.on_clear_button_clicked()714 self.media_item.on_clear_button_clicked()
696715
697 # THEN: The list_view and the search_edit should be cleared716 # THEN: The list_view and the search_edit should be cleared
698 self.assertEqual(self.media_item.current_results, [])717 self.assertEqual(self.media_item.current_results, [])
699 self.media_item.list_view.clear.assert_called_once_with()718 self.assertEqual(self.media_item.list_view.takeItem.call_count, 2)
700 self.media_item.search_edit.clear.assert_called_once_with()719 self.media_item.list_view.row.assert_has_calls([call('Some'), call('Results')])
701720
702 def test_on_save_results_button_clicked(self):721 def test_on_save_results_button_clicked(self):
703 """722 """
@@ -809,6 +828,7 @@
809 # to the dialog box828 # to the dialog box
810 self.media_item.second_bible = None829 self.media_item.second_bible = None
811 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})830 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})
831 self.media_item.saved_results = ['saved_results']
812 self.media_item.on_second_combo_box_index_changed(5)832 self.media_item.on_second_combo_box_index_changed(5)
813833
814 # THEN: The list_view should be cleared and the currently selected bible should not be channged834 # THEN: The list_view should be cleared and the currently selected bible should not be channged
@@ -836,6 +856,7 @@
836 # to the dialog box856 # to the dialog box
837 self.media_item.second_bible = None857 self.media_item.second_bible = None
838 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})858 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})
859 self.media_item.saved_results = ['saved_results']
839 self.media_item.on_second_combo_box_index_changed(5)860 self.media_item.on_second_combo_box_index_changed(5)
840861
841 # THEN: The selected bible should be set as the current bible862 # THEN: The selected bible should be set as the current bible
@@ -862,6 +883,7 @@
862 # to the dialog box883 # to the dialog box
863 self.media_item.second_bible = self.mocked_bible_1884 self.media_item.second_bible = self.mocked_bible_1
864 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': None})885 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': None})
886 self.media_item.saved_results = ['saved_results']
865 self.media_item.on_second_combo_box_index_changed(0)887 self.media_item.on_second_combo_box_index_changed(0)
866888
867 # THEN: The selected bible should be set as the current bible889 # THEN: The selected bible should be set as the current bible
@@ -902,6 +924,7 @@
902 self.media_item.select_book_combo_box = MagicMock(**{'currentData.return_value': 2})924 self.media_item.select_book_combo_box = MagicMock(**{'currentData.return_value': 2})
903 self.media_item.bible = self.mocked_bible_1925 self.media_item.bible = self.mocked_bible_1
904 self.mocked_plugin.manager.get_verse_count_by_book_ref_id.return_value = 6926 self.mocked_plugin.manager.get_verse_count_by_book_ref_id.return_value = 6
927 self.media_item.select_tab = MagicMock(**{'isVisible.return_value': True})
905 self.media_item.search_button = MagicMock()928 self.media_item.search_button = MagicMock()
906 with patch.object(self.media_item, 'adjust_combo_box') as mocked_adjust_combo_box:929 with patch.object(self.media_item, 'adjust_combo_box') as mocked_adjust_combo_box:
907 # WHEN: Calling on_advanced_book_combo_box930 # WHEN: Calling on_advanced_book_combo_box
@@ -1383,6 +1406,8 @@
1383 # 'bibles/is search while typing enabled' is requested1406 # 'bibles/is search while typing enabled' is requested
1384 self.setting_values = {'bibles/is search while typing enabled': True}1407 self.setting_values = {'bibles/is search while typing enabled': True}
1385 self.media_item.search_timer.isActive.return_value = False1408 self.media_item.search_timer.isActive.return_value = False
1409 self.media_item.bible = self.mocked_bible_1
1410 self.media_item.bible.is_web_bible = False
13861411
1387 # WHEN: Calling on_search_edit_text_changed1412 # WHEN: Calling on_search_edit_text_changed
1388 self.media_item.on_search_edit_text_changed()1413 self.media_item.on_search_edit_text_changed()
@@ -1402,7 +1427,7 @@
1402 self.media_item.on_search_timer_timeout()1427 self.media_item.on_search_timer_timeout()
14031428
1404 # THEN: The search_status should be set to SearchAsYouType and text_search should have been called1429 # THEN: The search_status should be set to SearchAsYouType and text_search should have been called
1405 self.assertEqual(self.media_item.search_status, SearchStatus().SearchAsYouType)1430 self.assertEqual(self.media_item.search_status, SearchStatus.SearchAsYouType)
1406 mocked_text_search.assert_called_once_with()1431 mocked_text_search.assert_called_once_with()
14071432
1408 def test_display_results_no_results(self):1433 def test_display_results_no_results(self):
14091434
=== modified file 'tests/interfaces/openlp_core_ui/test_projectoreditform.py'
--- tests/interfaces/openlp_core_ui/test_projectoreditform.py 2017-04-24 05:17:55 +0000
+++ tests/interfaces/openlp_core_ui/test_projectoreditform.py 2017-06-03 23:27:29 +0000
@@ -45,8 +45,8 @@
4545
46 :return: None46 :return: None
47 """47 """
48 self.setup_application()
48 self.build_settings()49 self.build_settings()
49 self.setup_application()
50 Registry.create()50 Registry.create()
51 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:51 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
52 if os.path.exists(TEST_DB):52 if os.path.exists(TEST_DB):
5353
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_manager.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2017-04-24 05:17:55 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2017-06-03 23:27:29 +0000
@@ -38,6 +38,7 @@
38 """38 """
39 Set up the environment for testing bible queries with 1 Timothy 339 Set up the environment for testing bible queries with 1 Timothy 3
40 """40 """
41 self.setup_application()
41 self.build_settings()42 self.build_settings()
42 Registry.create()43 Registry.create()
43 Registry().register('service_list', MagicMock())44 Registry().register('service_list', MagicMock())
4445
=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py'
--- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2017-05-26 13:30:54 +0000
+++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2017-06-03 23:27:29 +0000
@@ -38,6 +38,7 @@
38 """38 """
39 Set up the environment for testing bible parse reference39 Set up the environment for testing bible parse reference
40 """40 """
41 self.setup_application()
41 self.build_settings()42 self.build_settings()
42 Registry.create()43 Registry.create()
43 Registry().register('service_list', MagicMock())44 Registry().register('service_list', MagicMock())