[Openlp-core] [Merge] lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp
Azaziah has proposed merging lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp. Requested reviews: Tim Bentley (trb143) Raoul Snyman (raoul-snyman) Phill (phill-ridout) For more details, see: https://code.launchpad.net/~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick/+merge/306036 Fixed the issue where web bible's result in traceback in "Search while typing" (by removing one miss-placed line) This branch also fixes the issue where the new "Clear Bible search results" and "Lock button" give focus to Text search if it is used in "Select" tab. lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick (revision 2705) [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-01-Pull/1772/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-02-Functional-Tests/1683/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-03-Interface-Tests/1621/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/1377/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/967/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-05a-Code_Analysis/1035/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-05b-Test_Coverage/903/ [[1;32mSUCCESS[1;m] https://ci.openlp.io/job/Branch-05c-Code_Analysis2/66/ -- Your team OpenLP Core is subscribed to branch lp:openlp. === modified file 'openlp/core/ui/exceptiondialog.py' --- openlp/core/ui/exceptiondialog.py 2016-08-03 21:19:14 + +++ openlp/core/ui/exceptiondialog.py 2016-09-17 22:58:27 + @@ -97,9 +97,9 @@ translate('OpenLP.ExceptionDialog', 'Please describe what you were trying to do. ' 'If possible, write in English.')) exception_part1 = (translate('OpenLP.ExceptionDialog', - 'Oops, OpenLP hit a problem and couldn\'t recover! ' - 'You can help the OpenLP developers to fix this' - ' by sending them a bug report to {email}{newlines}' + 'Oops, OpenLP hit a problem and couldn\'t recover!' + 'You can help the OpenLP developers to fix this' + ' by sending them a bug report to {email}{newlines}' ).format(email=' b...@openlp.org', newlines='')) self.message_label.setText( === modified file 'openlp/plugins/bibles/lib/manager.py' --- openlp/plugins/bibles/lib/manager.py 2016-09-04 16:15:57 + +++ openlp/plugins/bibles/lib/manager.py 2016-09-17 22:58:27 + @@ -367,7 +367,6 @@ second_web_bible = self.db_cache[second_bible].get_object(BibleMeta, 'download_source') if web_bible or second_web_bible: # If either Bible is Web, cursor is reset to normal and search ends w/o any message. -self.check_search_result() self.application.set_normal_cursor() return None # Fetch the results from db. If no results are found, return None, no message is given for this. === modified file 'openlp/plugins/bibles/lib/mediaitem.py' --- openlp/plugins/bibles/lib/mediaitem.py 2016-08-10 18:31:33 + +++ openlp/plugins/bibles/lib/mediaitem.py 2016-09-17 22:58:27 + @@ -254,8 +254,8 @@ self.quickStyleComboBox.activated.connect(self.on_quick_style_combo_box_changed) self.advancedStyleComboBox.activated.connect(self.on_advanced_style_combo_box_changed) # Buttons -self.advancedClearButton.clicked.connect(self.on_clear_button) -self.quickClearButton.clicked.connect(self.on_clear_button) +self.advancedClearButton.clicked.connect(self.on_advanced_clear_button_clicked) +self.quickClearButton.clicked.connect(self.on_clear_button_clicked) self.advancedSearchButton.clicked.connect(self.on_advanced_search_button) self.quickSearchButton.clicked.connect(self.on_quick_search_button) # Other stuff @@ -548,19 +548,31 @@ self.advancedTab.setVisible(True) self.advanced_book_combo_box.setFocus() -def on_clear_button(self): +def on_clear_button_clicked(self): # Clear the list, then set the "No search Results" message, then clear the text field and give it focus. self.list_view.clear() self.check_search_result() self.quick_search_edit.clear() self.quick_search_edit.setFocus() +def on_advanced_clear_button_clicked(self): +# The same as the on_clear_button_clicked, but gives focus to Book name field in "Select" (advanced). +self.list_view.clear() +self.check_search_result() +self.advanced_book_combo_box.setFocus() + def on_lock_button_toggled(self, checked): -
Re: [Openlp-core] [Merge] lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp
It was my initial thought but I failed to set up the test within a reasonable time. Iv'e managed to increase the coverage by your instructions, thank you. > your test 'test_on_lock_button_toggled_search_tab' is only really testing the > last two lines of on_lock_button_toggled > > As, you've gone to all the trouble of setting this test up it would be easy to > test the if condition which sets the appropriate icon. In your current test > add: > > # GIVEN: > self.media_item.lock_icon = 'lock icon' > sender_instance_mock = MagicMock() > self.media_item.sender = MagicMock(return_value=sender_instance_mock) > > # THEN: > sender_instance_mock.setIcon.assert_called_once_with('lock icon') > > Then you can just copy and paste your test, make a few modifications calling > self.media_item.on_lock_button_toggled with False and you've provided 100% > coverage for the on_lock_button_toggled method, for not too much extra effort. > > See also my inline comment for one small issue with your current test. -- https://code.launchpad.net/~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick/+merge/306015 Your team OpenLP Core is subscribed to branch lp:openlp. ___ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp
[Openlp-core] [Merge] lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp
The proposal to merge lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp has been updated. Status: Needs review => Superseded For more details, see: https://code.launchpad.net/~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick/+merge/306015 -- Your team OpenLP Core is subscribed to branch lp:openlp. ___ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp
[Openlp-core] [Merge] lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp
The proposal to merge lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp has been updated. Status: Needs review => Superseded For more details, see: https://code.launchpad.net/~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick/+merge/306036 -- Your team OpenLP Core is subscribed to branch lp:openlp. ___ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp
Re: [Openlp-core] [Merge] lp:~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick into lp:openlp
your test 'test_on_lock_button_toggled_search_tab' is only really testing the last two lines of on_lock_button_toggled As, you've gone to all the trouble of setting this test up it would be easy to test the if condition which sets the appropriate icon. In your current test add: # GIVEN: self.media_item.lock_icon = 'lock icon' sender_instance_mock = MagicMock() self.media_item.sender = MagicMock(return_value=sender_instance_mock) # THEN: sender_instance_mock.setIcon.assert_called_once_with('lock icon') Then you can just copy and paste your test, make a few modifications calling self.media_item.on_lock_button_toggled with False and you've provided 100% coverage for the on_lock_button_toggled method, for not too much extra effort. See also my inline comment for one small issue with your current test. Diff comments: > > === modified file 'tests/functional/openlp_plugins/bibles/test_mediaitem.py' > --- tests/functional/openlp_plugins/bibles/test_mediaitem.py 2016-06-14 > 21:55:37 + > +++ tests/functional/openlp_plugins/bibles/test_mediaitem.py 2016-09-16 > 21:53:08 + > @@ -150,3 +150,36 @@ > self.assertEqual(2, > self.media_item.quickSearchButton.setEnabled.call_count, 'Disable and Enable > the button') > self.assertEqual(1, self.media_item.check_search_result.call_count, > 'Check results Should had been called once') > self.assertEqual(1, self.app.set_normal_cursor.call_count, 'Normal > cursor should had been called once') > + > +def test_on_clear_button_clicked(self): > +""" > +Test that the on_clear_button_clicked works properly. (Used by Bible > search tab) > +""" > +# GIVEN: Mocked list_view, check_search_results & quick_search_edit. > +self.media_item.list_view = MagicMock() > +self.media_item.check_search_result = MagicMock() > +self.media_item.quick_search_edit = MagicMock() > + > +# WHEN: on_clear_button_clicked is called > +self.media_item.on_clear_button_clicked() > + > +# THEN: Search result should be reset and search field should > receive focus. > +self.media_item.list_view.clear.assert_called_once_with(), > +self.media_item.check_search_result.assert_called_once_with(), > +self.media_item.quick_search_edit.clear.assert_called_once_with(), > +self.media_item.quick_search_edit.setFocus.assert_called_once_with() > + > +def test_on_lock_button_toggled_search_tab(self): > +""" > +Test that "on_lock_button_toggled" gives focus to the right field. > +""" > +# GIVEN: Mocked functions > +self.media_item.sender = MagicMock() > +self.media_item.quickTab = MagicMock() > +self.media_item.quick_search_edit = MagicMock() > + > +# WHEN: on_lock_button_toggled is called and quickTab.isVisible() > returns = True. quickTab.isVisible() isn't returning True, its returning an instance of MagicMock. For it to return True, you need to set the return_value on isVisable to True. You could do it like this: self.media_item.quickTab = MagicMock() self.media_item.quickTab.isVisable = MagicMock(return_value=True) but a as MagicMock automatically creates mocks for every method you call, you could also do it like: self.media_item.quickTab = MagicMock(**{'isVisible.return_value': True}) note in the above example we're unpacking a dictionary, because an keyword argument with a '.' in it isn't valid > +self.media_item.on_lock_button_toggled(True) > + > +# THEN: on_quick_search_edit should receive focus. > +self.media_item.quick_search_edit.setFocus.assert_called_once_with() -- https://code.launchpad.net/~suutari-olli/openlp/fix-advanced-bible-search-clear-button-giving-focus-to-quick/+merge/306015 Your team OpenLP Core is subscribed to branch lp:openlp. ___ Mailing list: https://launchpad.net/~openlp-core Post to : openlp-core@lists.launchpad.net Unsubscribe : https://launchpad.net/~openlp-core More help : https://help.launchpad.net/ListHelp
[Openlp-core] [Bug 1624661] [NEW] Missing DB results in Traceback
Public bug reported: When data folder was moved from E: to D:, the following traceback appears on startup after a few "Missing DB messages. Trunk 2696 | Win 10 Traceback (most recent call last): File "openlp.py", line 44, in main() File "D:\bzr\openlp\trunk\openlp\core\__init__.py", line 392, in main sys.exit(application.run(qt_args)) File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 59, in wrapped raise e File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 54, in wrapped return func(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\__init__.py", line 142, in run Registry().execute('bootstrap_initialise') File "D:\bzr\openlp\trunk\openlp\core\common\registry.py", line 137, in execute result = function(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 59, in wrapped raise e File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 54, in wrapped return func(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\lib\pluginmanager.py", line 59, in bootstrap_initialise self.hook_media_manager() File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 59, in wrapped raise e File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 54, in wrapped return func(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\lib\pluginmanager.py", line 123, in hook_media_manager plugin.create_media_manager_item() File "D:\bzr\openlp\trunk\openlp\core\lib\plugin.py", line 203, in create_media_manager_item self.media_item = self.media_item_class(self.main_window.media_dock_manager.media_dock, self) File "D:\bzr\openlp\trunk\openlp\plugins\images\lib\mediaitem.py", line 55, in __init__ super(ImageMediaItem, self).__init__(parent, plugin) File "D:\bzr\openlp\trunk\openlp\core\lib\mediamanageritem.py", line 83, in __init__ self.setup_item() File "D:\bzr\openlp\trunk\openlp\plugins\images\lib\mediaitem.py", line 68, in setup_item self.fill_groups_combobox(self.choose_group_form.group_combobox) File "D:\bzr\openlp\trunk\openlp\plugins\images\lib\mediaitem.py", line 300, in fill_groups_combobox image_groups = self.manager.get_all_objects(ImageGroups, ImageGroups.parent_id == parent_group_id) File "D:\bzr\openlp\trunk\openlp\core\lib\db.py", line 368, in get_all_objects query = self.session.query(object_class) AttributeError: 'NoneType' object has no attribute 'query' ** Affects: openlp Importance: Undecided Status: New ** Attachment added: "openlp.log" https://bugs.launchpad.net/bugs/1624661/+attachment/4742577/+files/openlp.log -- You received this bug notification because you are a member of OpenLP Core, which is subscribed to OpenLP. https://bugs.launchpad.net/bugs/1624661 Title: Missing DB results in Traceback Status in OpenLP: New Bug description: When data folder was moved from E: to D:, the following traceback appears on startup after a few "Missing DB messages. Trunk 2696 | Win 10 Traceback (most recent call last): File "openlp.py", line 44, in main() File "D:\bzr\openlp\trunk\openlp\core\__init__.py", line 392, in main sys.exit(application.run(qt_args)) File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 59, in wrapped raise e File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 54, in wrapped return func(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\__init__.py", line 142, in run Registry().execute('bootstrap_initialise') File "D:\bzr\openlp\trunk\openlp\core\common\registry.py", line 137, in execute result = function(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 59, in wrapped raise e File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 54, in wrapped return func(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\lib\pluginmanager.py", line 59, in bootstrap_initialise self.hook_media_manager() File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 59, in wrapped raise e File "D:\bzr\openlp\trunk\openlp\core\common\openlpmixin.py", line 54, in wrapped return func(*args, **kwargs) File "D:\bzr\openlp\trunk\openlp\core\lib\pluginmanager.py", line 123, in hook_media_manager plugin.create_media_manager_item() File "D:\bzr\openlp\trunk\openlp\core\lib\plugin.py", line 203, in create_media_manager_item self.media_item = self.media_item_class(self.main_window.media_dock_manager.media_dock, self) File "D:\bzr\openlp\trunk\openlp\plugins\images\lib\mediaitem.py", line 55, in __init__ super(ImageMediaItem, self).__init__(parent, plugin) File "D:\bzr\openlp\trunk\openlp\core\lib\mediamanageritem.py", line 83, in __init__ self.setup_item() File "D:\bzr\openlp\trunk\openlp\plugins\images\lib\mediaitem.py",