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
1=== modified file 'tests/functional/openlp_core_lib/test_renderer.py'
2--- tests/functional/openlp_core_lib/test_renderer.py 2017-05-23 05:00:42 +0000
3+++ tests/functional/openlp_core_lib/test_renderer.py 2017-06-03 23:27:29 +0000
4@@ -182,13 +182,15 @@
5 @patch('openlp.core.lib.renderer.QtWebKitWidgets.QWebView')
6 @patch('openlp.core.lib.renderer.build_lyrics_format_css')
7 @patch('openlp.core.lib.renderer.build_lyrics_outline_css')
8- def test_set_text_rectangle(self, mock_outline_css, mock_lyrics_css, mock_webview):
9+ @patch('openlp.core.lib.renderer.build_chords_css')
10+ def test_set_text_rectangle(self, mock_build_chords_css, mock_outline_css, mock_lyrics_css, mock_webview):
11 """
12 Test set_text_rectangle returns a proper html string
13 """
14 # GIVEN: test object and data
15 mock_lyrics_css.return_value = ' FORMAT CSS; '
16 mock_outline_css.return_value = ' OUTLINE CSS; '
17+ mock_build_chords_css.return_value = ' CHORDS CSS; '
18 theme_data = Theme()
19 theme_data.font_main_name = 'Arial'
20 theme_data.font_main_size = 20
21
22=== modified file 'tests/functional/openlp_plugins/bibles/test_mediaitem.py'
23--- tests/functional/openlp_plugins/bibles/test_mediaitem.py 2017-04-03 20:28:16 +0000
24+++ tests/functional/openlp_plugins/bibles/test_mediaitem.py 2017-06-03 23:27:29 +0000
25@@ -31,7 +31,7 @@
26
27 from openlp.core.common import Registry
28 from openlp.core.lib import MediaManagerItem
29-from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch, ResultsTab, SearchStatus, \
30+from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem, BibleSearch, ResultsTab, SearchStatus, SearchTabs, \
31 get_reference_separators, VALID_TEXT_SEARCH
32
33
34@@ -206,29 +206,63 @@
35 """
36 Test the correct widget gets focus when the BibleMediaItem receives focus
37 """
38- # GIVEN: An instance of :class:`MediaManagerItem` and a mocked out search_tab and search_edit
39+ # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
40 self.media_item.search_tab = MagicMock(**{'isVisible.return_value': True})
41 self.media_item.search_edit = MagicMock()
42-
43- # WHEN: Calling on_focus
44- self.media_item.on_focus()
45-
46- # THEN: setFocus and selectAll should have been called on search_edit
47- self.assertEqual(self.media_item.search_edit.mock_calls, [call.setFocus(), call.selectAll()])
48-
49- def test_on_focus_search_tab_not_visible(self):
50- """
51- Test the correct widget gets focus when the BibleMediaItem receives focus
52- """
53- # GIVEN: An instance of :class:`MediaManagerItem` and a mocked out search_tab and select_book_combo_box
54- self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
55- self.media_item.select_book_combo_box = MagicMock()
56-
57- # WHEN: Calling on_focus
58- self.media_item.on_focus()
59-
60- # THEN: setFocus should have been called on select_book_combo_box
61- self.assertTrue(self.media_item.select_book_combo_box.setFocus.called)
62+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': False})
63+ self.media_item.select_book_combo_box = MagicMock()
64+ self.media_item.options_tab = MagicMock(**{'isVisible.return_value': False})
65+ self.media_item.version_combo_box = MagicMock()
66+
67+ # WHEN: Calling on_focus
68+ self.media_item.on_focus()
69+
70+ # THEN: search_edit should now have focus and its text selected
71+ self.media_item.search_edit.assert_has_calls([call.setFocus(), call.selectAll()])
72+ self.media_item.select_book_combo_box.assert_not_called()
73+ self.media_item.version_combo_box.setFocus.assert_not_called()
74+
75+ def test_on_focus_select_tab_visible(self):
76+ """
77+ Test the correct widget gets focus when the BibleMediaItem receives focus
78+ """
79+ # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
80+ self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
81+ self.media_item.search_edit = MagicMock()
82+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': True})
83+ self.media_item.select_book_combo_box = MagicMock()
84+ self.media_item.options_tab = MagicMock(**{'isVisible.return_value': False})
85+ self.media_item.version_combo_box = MagicMock()
86+
87+ # WHEN: Calling on_focus
88+ self.media_item.on_focus()
89+
90+ # THEN: select_book_combo_box should have focus
91+ self.media_item.search_edit.setFocus.assert_not_called()
92+ self.media_item.search_edit.selectAll.assert_not_called()
93+ self.media_item.select_book_combo_box.setFocus.assert_called_once_with()
94+ self.media_item.version_combo_box.setFocus.assert_not_called()
95+
96+ def test_on_focus_options_tab_visible(self):
97+ """
98+ Test the correct widget gets focus when the BibleMediaItem receives focus
99+ """
100+ # GIVEN: An instance of :class:`MediaManagerItem` and mocked out tabs and primary widgets
101+ self.media_item.search_tab = MagicMock(**{'isVisible.return_value': False})
102+ self.media_item.search_edit = MagicMock()
103+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': False})
104+ self.media_item.select_book_combo_box = MagicMock()
105+ self.media_item.options_tab = MagicMock(**{'isVisible.return_value': True})
106+ self.media_item.version_combo_box = MagicMock()
107+
108+ # WHEN: Calling on_focus
109+ self.media_item.on_focus()
110+
111+ # THEN: version_combo_box have received focus
112+ self.media_item.search_edit.setFocus.assert_not_called()
113+ self.media_item.search_edit.selectAll.assert_not_called()
114+ self.media_item.select_book_combo_box.setFocus.assert_not_called()
115+ self.media_item.version_combo_box.setFocus.assert_called_once_with()
116
117 def test_config_update_show_second_bible(self):
118 """
119@@ -611,12 +645,15 @@
120 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab
121 self.media_item.search_tab = MagicMock()
122 self.media_item.select_tab = MagicMock()
123+ self.media_item.options_tab = MagicMock()
124+ self.media_item.search_button = MagicMock()
125 with patch.object(self.media_item, 'on_focus'):
126
127 # WHEN: The search_tab has been selected
128- self.media_item.on_search_tab_bar_current_changed(0)
129+ self.media_item.on_search_tab_bar_current_changed(SearchTabs.Search)
130
131- # THEN: search_tab should be setVisible and select_tab should be hidder
132+ # THEN: The search_button should be enabled, search_tab should be setVisible and select_tab should be hidden
133+ self.media_item.search_button.setEnabled.assert_called_once_with(True)
134 self.media_item.search_tab.setVisible.assert_called_once_with(True)
135 self.media_item.select_tab.setVisible.assert_called_once_with(False)
136
137@@ -627,12 +664,15 @@
138 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab
139 self.media_item.search_tab = MagicMock()
140 self.media_item.select_tab = MagicMock()
141+ self.media_item.options_tab = MagicMock()
142+ self.media_item.search_button = MagicMock()
143 with patch.object(self.media_item, 'on_focus'):
144
145 # WHEN: The select_tab has been selected
146- self.media_item.on_search_tab_bar_current_changed(1)
147+ self.media_item.on_search_tab_bar_current_changed(SearchTabs.Select)
148
149- # THEN: search_tab should be setVisible and select_tab should be hidder
150+ # THEN: The search_button should be enabled, select_tab should be setVisible and search_tab should be hidden
151+ self.media_item.search_button.setEnabled.assert_called_once_with(True)
152 self.media_item.search_tab.setVisible.assert_called_once_with(False)
153 self.media_item.select_tab.setVisible.assert_called_once_with(True)
154
155@@ -660,44 +700,23 @@
156 # THEN: The select_book_combo_box model sort should have been reset
157 self.media_item.select_book_combo_box.model().sort.assert_called_once_with(-1)
158
159- def test_on_clear_button_clicked_saved_tab(self):
160- """
161- Test on_clear_button_clicked when the saved tab is selected
162- """
163- # GIVEN: An instance of :class:`MediaManagerItem` and mocked out saved_tab and select_tab and a mocked out
164- # list_view and search_edit
165- self.media_item.list_view = MagicMock()
166- self.media_item.search_edit = MagicMock()
167- self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Saved})
168- self.media_item.saved_results = ['Some', 'Results']
169- with patch.object(self.media_item, 'on_focus'):
170-
171- # WHEN: Calling on_clear_button_clicked
172- self.media_item.on_clear_button_clicked()
173-
174- # THEN: The list_view should be cleared
175- self.assertEqual(self.media_item.saved_results, [])
176- self.media_item.list_view.clear.assert_called_once_with()
177-
178- def test_on_clear_button_clicked_search_tab(self):
179+ def test_on_clear_button_clicked(self):
180 """
181 Test on_clear_button_clicked when the search tab is selected
182 """
183 # GIVEN: An instance of :class:`MediaManagerItem` and mocked out search_tab and select_tab and a mocked out
184 # list_view and search_edit
185- self.media_item.list_view = MagicMock()
186- self.media_item.search_edit = MagicMock()
187+ self.media_item.list_view = MagicMock(**{'selectedItems.return_value': ['Some', 'Results']})
188 self.media_item.results_view_tab = MagicMock(**{'currentIndex.return_value': ResultsTab.Search})
189- self.media_item.current_results = ['Some', 'Results']
190- with patch.object(self.media_item, 'on_focus'):
191+ with patch.object(self.media_item, 'on_results_view_tab_total_update'):
192
193 # WHEN: Calling on_clear_button_clicked
194 self.media_item.on_clear_button_clicked()
195
196 # THEN: The list_view and the search_edit should be cleared
197 self.assertEqual(self.media_item.current_results, [])
198- self.media_item.list_view.clear.assert_called_once_with()
199- self.media_item.search_edit.clear.assert_called_once_with()
200+ self.assertEqual(self.media_item.list_view.takeItem.call_count, 2)
201+ self.media_item.list_view.row.assert_has_calls([call('Some'), call('Results')])
202
203 def test_on_save_results_button_clicked(self):
204 """
205@@ -809,6 +828,7 @@
206 # to the dialog box
207 self.media_item.second_bible = None
208 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})
209+ self.media_item.saved_results = ['saved_results']
210 self.media_item.on_second_combo_box_index_changed(5)
211
212 # THEN: The list_view should be cleared and the currently selected bible should not be channged
213@@ -836,6 +856,7 @@
214 # to the dialog box
215 self.media_item.second_bible = None
216 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': self.mocked_bible_1})
217+ self.media_item.saved_results = ['saved_results']
218 self.media_item.on_second_combo_box_index_changed(5)
219
220 # THEN: The selected bible should be set as the current bible
221@@ -862,6 +883,7 @@
222 # to the dialog box
223 self.media_item.second_bible = self.mocked_bible_1
224 self.media_item.second_combo_box = MagicMock(**{'currentData.return_value': None})
225+ self.media_item.saved_results = ['saved_results']
226 self.media_item.on_second_combo_box_index_changed(0)
227
228 # THEN: The selected bible should be set as the current bible
229@@ -902,6 +924,7 @@
230 self.media_item.select_book_combo_box = MagicMock(**{'currentData.return_value': 2})
231 self.media_item.bible = self.mocked_bible_1
232 self.mocked_plugin.manager.get_verse_count_by_book_ref_id.return_value = 6
233+ self.media_item.select_tab = MagicMock(**{'isVisible.return_value': True})
234 self.media_item.search_button = MagicMock()
235 with patch.object(self.media_item, 'adjust_combo_box') as mocked_adjust_combo_box:
236 # WHEN: Calling on_advanced_book_combo_box
237@@ -1383,6 +1406,8 @@
238 # 'bibles/is search while typing enabled' is requested
239 self.setting_values = {'bibles/is search while typing enabled': True}
240 self.media_item.search_timer.isActive.return_value = False
241+ self.media_item.bible = self.mocked_bible_1
242+ self.media_item.bible.is_web_bible = False
243
244 # WHEN: Calling on_search_edit_text_changed
245 self.media_item.on_search_edit_text_changed()
246@@ -1402,7 +1427,7 @@
247 self.media_item.on_search_timer_timeout()
248
249 # THEN: The search_status should be set to SearchAsYouType and text_search should have been called
250- self.assertEqual(self.media_item.search_status, SearchStatus().SearchAsYouType)
251+ self.assertEqual(self.media_item.search_status, SearchStatus.SearchAsYouType)
252 mocked_text_search.assert_called_once_with()
253
254 def test_display_results_no_results(self):
255
256=== modified file 'tests/interfaces/openlp_core_ui/test_projectoreditform.py'
257--- tests/interfaces/openlp_core_ui/test_projectoreditform.py 2017-04-24 05:17:55 +0000
258+++ tests/interfaces/openlp_core_ui/test_projectoreditform.py 2017-06-03 23:27:29 +0000
259@@ -45,8 +45,8 @@
260
261 :return: None
262 """
263+ self.setup_application()
264 self.build_settings()
265- self.setup_application()
266 Registry.create()
267 with patch('openlp.core.lib.projector.db.init_url') as mocked_init_url:
268 if os.path.exists(TEST_DB):
269
270=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_manager.py'
271--- tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2017-04-24 05:17:55 +0000
272+++ tests/interfaces/openlp_plugins/bibles/test_lib_manager.py 2017-06-03 23:27:29 +0000
273@@ -38,6 +38,7 @@
274 """
275 Set up the environment for testing bible queries with 1 Timothy 3
276 """
277+ self.setup_application()
278 self.build_settings()
279 Registry.create()
280 Registry().register('service_list', MagicMock())
281
282=== modified file 'tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py'
283--- tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2017-05-26 13:30:54 +0000
284+++ tests/interfaces/openlp_plugins/bibles/test_lib_parse_reference.py 2017-06-03 23:27:29 +0000
285@@ -38,6 +38,7 @@
286 """
287 Set up the environment for testing bible parse reference
288 """
289+ self.setup_application()
290 self.build_settings()
291 Registry.create()
292 Registry().register('service_list', MagicMock())