diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py
index 91fd6bfd7..8942643c0 100644
--- a/openlp/plugins/bibles/lib/mediaitem.py
+++ b/openlp/plugins/bibles/lib/mediaitem.py
@@ -684,6 +684,36 @@ class BibleMediaItem(MediaManagerItem):
self.second_search_results = \
self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id)
+ def banana(self):
+ # We are doing a 'Reference Search'.
+ # Set Bibles to use the text input from Quick search field.
+ bible = self.quickVersionComboBox.currentText()
+ second_bible = self.quickSecondComboBox.currentText()
+ text = self.quick_search_edit.text()
+ text = text.replace('. ', ' ')
+ if self.quick_search_edit.current_search_type() == BibleSearch.Reference:
+ self.search_results = self.plugin.manager.get_verses(bible, text)
+ if not self.search_results:
+ # if nothing is found, message is given.
+ # Get reference separators from settings.
+ reference_separators = {
+ 'verse': get_reference_separator('sep_v_display'),
+ 'range': get_reference_separator('sep_r_display'),
+ 'list': get_reference_separator('sep_l_display')}
+ self.main_window.information_message(
+ translate('BiblesPlugin.BibleManager', 'Scripture Reference Error'),
+ translate('BiblesPlugin.BibleManager', 'OpenLP couldn’t find anything '
+ 'with your search.
'
+ 'Please make sure that your reference follows one of these patterns:
%s'
+ % UiStrings().BibleScriptureError % reference_separators))
+ elif self.quick_search_edit.current_search_type() == BibleSearch.Combined:
+ # In Combined Reference search no error is given if no results are found. (This would result in duplicate)
+ self.search_results = self.plugin.manager.get_verses(bible, text)
+ if second_bible and self.search_results:
+ self.second_search_results = \
+ self.plugin.manager.get_verses(second_bible, text, self.search_results[0].book.book_reference_id)
+ self.advancedSearchButton.setEnabled(True)
+
def on_quick_text_search(self):
# We are doing a 'Text Search'.
# Set Bibles to use the text input from Quick search field.
diff --git a/tests/functional/openlp_plugins/bibles/test_mediaitem.py b/tests/functional/openlp_plugins/bibles/test_mediaitem.py
index a3ce92f4d..112448d73 100644
--- a/tests/functional/openlp_plugins/bibles/test_mediaitem.py
+++ b/tests/functional/openlp_plugins/bibles/test_mediaitem.py
@@ -23,6 +23,8 @@
This module contains tests for the lib submodule of the Presentations plugin.
"""
from unittest import TestCase
+
+from openlp.core.common import Registry, Settings
from openlp.plugins.bibles.lib.mediaitem import BibleMediaItem
from tests.functional import MagicMock, patch
from tests.helpers.testmixin import TestMixin
@@ -41,6 +43,9 @@ class TestMediaItem(TestCase, TestMixin):
patch('openlp.plugins.bibles.lib.mediaitem.BibleMediaItem.setup_item'):
self.media_item = BibleMediaItem(None, MagicMock())
self.setup_application()
+ self.mocked_main_window = MagicMock()
+ Registry.create()
+ Registry().register('main_window', self.mocked_main_window)
def display_results_no_results_test(self):
"""
@@ -109,3 +114,49 @@ class TestMediaItem(TestCase, TestMixin):
mocked_list_view.selectAll.assert_called_once_with()
self.assertEqual(self.media_item.search_results, {})
self.assertEqual(self.media_item.second_search_results, {})
+
+ def on_quick_reference_search_test(self):
+ """
+ BOOM BOOM BANANAS
+ """
+
+ # GIVEN: A mocked build_display_results which returns an empty list
+ self.media_item.quickVersionComboBox = MagicMock()
+ self.media_item.quickSecondComboBox = MagicMock()
+ self.media_item.quick_search_edit = MagicMock()
+
+ #mocked_text = self.media_item()
+ #mocked_text.text.return_value = 'Gen. 1'
+ #self.media_item.text = mocked_text
+ #self.media_item.text.return_value = 'Gen. 1'
+ # self.mocked_main_window.information_message = MagicMock()
+
+ self.media_item.search_results = MagicMock()
+ self.media_item.advancedSearchButton = MagicMock()
+ self.media_item.advancedSearchButton.setEnabled = MagicMock()
+
+ # WHEN: Calling display_results with a single bible version
+ self.media_item.banana()
+
+ # THEN: No items should be added to the list, and select all should have been called.
+ # self.assertEqual(0, self.mocked_main_window.information_message, 'lama')
+ # mocked_media_item.assert_called_with(mocked_main_window.information_message)
+ # self.mocked_text.text.assert_called_with('Gen. 1')
+ # mocked_process_item.assert_called_once_with(mocked_item, 7)
+ self.media_item.advancedSearchButton.setEnabled.assert_called_once_with(True)
+
+
+ """
+ def on_quick_reference_search_test(self):
+
+ Test the display_results method a large number of results (> 100) are returned
+
+
+ # GIVEN: A mocked build_display_results which returns a large list of results
+ media_item = BibleMediaItem(MagicMock)
+
+ # WHEN: Calling display_results
+ #self.media_item.on_quick_reference_search()
+
+ # THEN: addItem should have been called 100 times, and the lsit items should not be selected.
+ """
\ No newline at end of file