openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #31698
[Merge] lp:~phill-ridout/openlp/test-fixes into lp:openlp
Phill has proposed merging lp:~phill-ridout/openlp/test-fixes into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/test-fixes/+merge/325038
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
--
Your team OpenLP Core is subscribed to branch lp:openlp.
=== 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 22:57:25 +0000
@@ -182,13 +182,15 @@
@patch('openlp.core.lib.renderer.QtWebKitWidgets.QWebView')
@patch('openlp.core.lib.renderer.build_lyrics_format_css')
@patch('openlp.core.lib.renderer.build_lyrics_outline_css')
- def test_set_text_rectangle(self, mock_outline_css, mock_lyrics_css, mock_webview):
+ @patch('openlp.core.lib.renderer.build_chords_css')
+ def test_set_text_rectangle(self, mock_build_chords_css, mock_outline_css, mock_lyrics_css, mock_webview):
"""
Test set_text_rectangle returns a proper html string
"""
# GIVEN: test object and data
mock_lyrics_css.return_value = ' FORMAT CSS; '
mock_outline_css.return_value = ' OUTLINE CSS; '
+ mock_build_chords_css.return_value = ' CHORDS CSS; '
theme_data = Theme()
theme_data.font_main_name = 'Arial'
theme_data.font_main_size = 20
=== 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 22:57:25 +0000
@@ -31,7 +31,7 @@
from openlp.core.common import Registry
from openlp.core.lib import MediaManagerItem
-from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch, ResultsTab, SearchStatus, \
+from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch, ResultsTab, SearchStatus, SearchTabs, \
get_reference_separators, VALID_TEXT_SEARCH
@@ -206,29 +206,63 @@
"""
Test the correct widget gets focus when the BibleMediaItem receives focus
"""
- # GIVEN: An instance of :class:`MediaManagerItem` and a mocked out search_tab and search_edit
+ # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
self.media_item.search_tab = MagicMock(**{'isVisible.return_value': True})
self.media_item.search_edit = MagicMock()
-
- # WHEN: Calling on_focus
- self.media_item.on_focus()
-
- # THEN: setFocus and selectAll should have been called on search_edit
- self.assertEqual(self.media_item.search_edit.mock_calls, [call.setFocus(), call.selectAll()])
-
- def test_on_focus_search_tab_not_visible(self):
- """
- Test the correct widget gets focus when the BibleMediaItem receives focus
- """
- # GIVEN: An instance of :class:`MediaManagerItem` and a mocked out search_tab and select_book_combo_box
- self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
- self.media_item.select_book_combo_box = MagicMock()
-
- # WHEN: Calling on_focus
- self.media_item.on_focus()
-
- # THEN: setFocus should have been called on select_book_combo_box
- self.assertTrue(self.media_item.select_book_combo_box.setFocus.called)
+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': False})
+ self.media_item.select_book_combo_box = MagicMock()
+ self.media_item.options_tab = MagicMock(**{'isVisible.return_value': False})
+ self.media_item.version_combo_box = MagicMock()
+
+ # WHEN: Calling on_focus
+ self.media_item.on_focus()
+
+ # THEN: search_edit should now have focus and its text selected
+ self.media_item.search_edit.assert_has_calls([call.setFocus(), call.selectAll()])
+ self.media_item.select_book_combo_box.assert_not_called()
+ self.media_item.version_combo_box.setFocus.assert_not_called()
+
+ def test_on_focus_select_tab_visible(self):
+ """
+ Test the correct widget gets focus when the BibleMediaItem receives focus
+ """
+ # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
+ self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
+ self.media_item.search_edit = MagicMock()
+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': True})
+ self.media_item.select_book_combo_box = MagicMock()
+ self.media_item.options_tab = MagicMock(**{'isVisible.return_value': False})
+ self.media_item.version_combo_box = MagicMock()
+
+ # WHEN: Calling on_focus
+ self.media_item.on_focus()
+
+ # THEN: select_book_combo_box should have focus
+ self.media_item.search_edit.setFocus.assert_not_called()
+ self.media_item.search_edit.selectAll.assert_not_called()
+ self.media_item.select_book_combo_box.setFocus.assert_called_once_with()
+ self.media_item.version_combo_box.setFocus.assert_not_called()
+
+ def test_on_focus_options_tab_visible(self):
+ """
+ Test the correct widget gets focus when the BibleMediaItem receives focus
+ """
+ # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
+ self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
+ self.media_item.search_edit = MagicMock()
+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': False})
+ self.media_item.select_book_combo_box = MagicMock()
+ self.media_item.options_tab = MagicMock(**{'isVisible.return_value': True})
+ self.media_item.version_combo_box = MagicMock()
+
+ # WHEN: Calling on_focus
+ self.media_item.on_focus()
+
+ # THEN: version_combo_box have received focus
+ self.media_item.search_edit.setFocus.assert_not_called()
+ self.media_item.search_edit.selectAll.assert_not_called()
+ self.media_item.select_book_combo_box.setFocus.assert_not_called()
+ self.media_item.version_combo_box.setFocus.assert_called_once_with()
def test_config_update_show_second_bible(self):
"""
@@ -611,12 +645,15 @@
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab
self.media_item.search_tab = MagicMock()
self.media_item.select_tab = MagicMock()
+ self.media_item.options_tab = MagicMock()
+ self.media_item.search_button = MagicMock()
with patch.object(self.media_item, 'on_focus'):
# WHEN: The search_tab has been selected
- self.media_item.on_search_tab_bar_current_changed(0)
+ self.media_item.on_search_tab_bar_current_changed(SearchTabs.Search)
- # THEN: search_tab should be setVisible and select_tab should be hidder
+ # THEN: The search_button should be enabled, search_tab should be setVisible and select_tab should be hidden
+ self.media_item.search_button.setEnabled.assert_called_once_with(True)
self.media_item.search_tab.setVisible.assert_called_once_with(True)
self.media_item.select_tab.setVisible.assert_called_once_with(False)
@@ -627,12 +664,15 @@
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab
self.media_item.search_tab = MagicMock()
self.media_item.select_tab = MagicMock()
+ self.media_item.options_tab = MagicMock()
+ self.media_item.search_button = MagicMock()
with patch.object(self.media_item, 'on_focus'):
# WHEN: The select_tab has been selected
- self.media_item.on_search_tab_bar_current_changed(1)
+ self.media_item.on_search_tab_bar_current_changed(SearchTabs.Select)
- # THEN: search_tab should be setVisible and select_tab should be hidder
+ # THEN: The search_button should be enabled, select_tab should be setVisible and search_tab should be hidden
+ self.media_item.search_button.setEnabled.assert_called_once_with(True)
self.media_item.search_tab.setVisible.assert_called_once_with(False)
self.media_item.select_tab.setVisible.assert_called_once_with(True)
@@ -660,44 +700,23 @@
# THEN: The select_book_combo_box model sort should have been reset
self.media_item.select_book_combo_box.model().sort.assert_called_once_with(-1)
- def test_on_clear_button_clicked_saved_tab(self):
- """
- Test on_clear_button_clicked when the saved tab is selected
- """
- # GIVEN: An instance of :class:`MediaManagerItem` and mocked out saved_tab and select_tab and a mocked out
- # list_view and search_edit
- self.media_item.list_view = MagicMock()
- self.media_item.search_edit = MagicMock()
- self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Saved})
- self.media_item.saved_results = ['Some', 'Results']
- with patch.object(self.media_item, 'on_focus'):
-
- # WHEN: Calling on_clear_button_clicked
- self.media_item.on_clear_button_clicked()
-
- # THEN: The list_view should be cleared
- self.assertEqual(self.media_item.saved_results, [])
- self.media_item.list_view.clear.assert_called_once_with()
-
- def test_on_clear_button_clicked_search_tab(self):
+ def test_on_clear_button_clicked(self):
"""
Test on_clear_button_clicked when the search tab is selected
"""
# GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab and a mocked out
# list_view and search_edit
- self.media_item.list_view = MagicMock()
- self.media_item.search_edit = MagicMock()
+ self.media_item.list_view = MagicMock(**{'selectedItems.return_value': ['Some', 'Results']})
self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Search})
- self.media_item.current_results = ['Some', 'Results']
- with patch.object(self.media_item, 'on_focus'):
+ with patch.object(self.media_item, 'on_results_view_tab_total_update'):
# WHEN: Calling on_clear_button_clicked
self.media_item.on_clear_button_clicked()
# THEN: The list_view and the search_edit should be cleared
self.assertEqual(self.media_item.current_results, [])
- self.media_item.list_view.clear.assert_called_once_with()
- self.media_item.search_edit.clear.assert_called_once_with()
+ self.assertEqual(self.media_item.list_view.takeItem.call_count, 2)
+ self.media_item.list_view.row.assert_has_calls([call('Some'), call('Results')])
def test_on_save_results_button_clicked(self):
"""
@@ -809,6 +828,7 @@
# to the dialog box
self.media_item.second_bible = None
self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})
+ self.media_item.saved_results = ['saved_results']
self.media_item.on_second_combo_box_index_changed(5)
# THEN: The list_view should be cleared and the currently selected bible should not be channged
@@ -836,6 +856,7 @@
# to the dialog box
self.media_item.second_bible = None
self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})
+ self.media_item.saved_results = ['saved_results']
self.media_item.on_second_combo_box_index_changed(5)
# THEN: The selected bible should be set as the current bible
@@ -862,6 +883,7 @@
# to the dialog box
self.media_item.second_bible = self.mocked_bible_1
self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': None})
+ self.media_item.saved_results = ['saved_results']
self.media_item.on_second_combo_box_index_changed(0)
# THEN: The selected bible should be set as the current bible
@@ -902,6 +924,7 @@
self.media_item.select_book_combo_box = MagicMock(**{'currentData.return_value': 2})
self.media_item.bible = self.mocked_bible_1
self.mocked_plugin.manager.get_verse_count_by_book_ref_id.return_value = 6
+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': True})
self.media_item.search_button = MagicMock()
with patch.object(self.media_item, 'adjust_combo_box') as mocked_adjust_combo_box:
# WHEN: Calling on_advanced_book_combo_box
@@ -1383,6 +1406,8 @@
# 'bibles/is search while typing enabled' is requested
self.setting_values = {'bibles/is search while typing enabled': True}
self.media_item.search_timer.isActive.return_value = False
+ self.media_item.bible = self.mocked_bible_1
+ self.media_item.bible.is_web_bible = False
# WHEN: Calling on_search_edit_text_changed
self.media_item.on_search_edit_text_changed()
@@ -1402,7 +1427,7 @@
self.media_item.on_search_timer_timeout()
# THEN: The search_status should be set to SearchAsYouType and text_search should have been called
- self.assertEqual(self.media_item.search_status, SearchStatus().SearchAsYouType)
+ self.assertEqual(self.media_item.search_status, SearchStatus.SearchAsYouType)
mocked_text_search.assert_called_once_with()
def test_display_results_no_results(self):
Follow ups