← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/broken_search into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/broken_search into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~trb143/openlp/broken_search/+merge/282232

Why now, no idea but remote stopped working when a string number is passed instead of an int.

lp:~trb143/openlp/broken_search (revision 2588)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/1242/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/1166/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1105/
[FAILURE] https://ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/942/

-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/broken_search into lp:openlp.
=== modified file 'openlp/plugins/remotes/lib/httprouter.py'
--- openlp/plugins/remotes/lib/httprouter.py	2015-12-31 22:46:06 +0000
+++ openlp/plugins/remotes/lib/httprouter.py	2016-01-11 22:01:57 +0000
@@ -621,7 +621,7 @@
         event = getattr(self.service_manager, 'servicemanager_%s_item' % action)
         if self.request_data:
             try:
-                data = json.loads(self.request_data)['request']['id']
+                data = int(json.loads(self.request_data)['request']['id'])
             except KeyError:
                 return self.do_http_error()
             event.emit(data)

=== added file 'tests/functional/openlp_plugins/media/test_mediaitem.py'
--- tests/functional/openlp_plugins/media/test_mediaitem.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/media/test_mediaitem.py	2016-01-11 22:01:57 +0000
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2016 OpenLP Developers                                   #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
+# more details.                                                               #
+#                                                                             #
+# You should have received a copy of the GNU General Public License along     #
+# with this program; if not, write to the Free Software Foundation, Inc., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+"""
+Test the media plugin
+"""
+from unittest import TestCase
+
+from openlp.core import Registry, Settings
+from openlp.plugins.media.mediaplugin import MediaPlugin
+from openlp.plugins.media.lib.mediaitem import MediaMediaItem
+from openlp.core.ui.media.mediacontroller import MediaController
+
+from PyQt5 import QtCore
+
+from tests.functional import MagicMock, patch
+from tests.helpers.testmixin import TestMixin
+
+__default_settings__ = {
+    'media/media auto start': QtCore.Qt.Unchecked,
+    'media/media files': []
+}
+
+
+class MediaItemTest(TestCase, TestMixin):
+    """
+    Test the media item for Media
+    """
+
+    def setUp(self):
+        """
+        Set up the components need for all tests.
+        """
+        with patch('openlp.plugins.media.lib.mediaitem.MediaManagerItem.__init__'),\
+                patch('openlp.plugins.media.lib.mediaitem.MediaMediaItem.setup'):
+            self.media_item = MediaMediaItem(None, MagicMock())
+            self.media_item.settings_section = 'media'
+        self.setup_application()
+        self.build_settings()
+        Settings().extend_default_settings(__default_settings__)
+
+    def tearDown(self):
+        """
+        Clean up after the tests
+        """
+        self.destroy_settings()
+
+    def test_search_found(self):
+        """
+        Media Remote Search Successful find
+        """
+        # GIVEN: The Mediaitem set up a list of media
+        Settings().setValue(self.media_item.settings_section + '/media files', ['test.mp3', 'test.mp4'])
+        # WHEN: Retrieving the test file
+        result = self.media_item.search('test.mp4', False)
+        # THEN: a file should be found
+        self.assertEqual(result, [['test.mp4', 'test.mp4']], 'The result file contain the file name')
+
+    def test_search_not_found(self):
+        """
+        Media Remote Search not find
+        """
+        # GIVEN: The Mediaitem set up a list of media
+        Settings().setValue(self.media_item.settings_section + '/media files', ['test.mp3', 'test.mp4'])
+        # WHEN: Retrieving the test file
+        result = self.media_item.search('test.mpx', False)
+        # THEN: a file should be found
+        self.assertEqual(result, [], 'The result file should be empty')

=== modified file 'tests/functional/openlp_plugins/remotes/test_router.py'
--- tests/functional/openlp_plugins/remotes/test_router.py	2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_plugins/remotes/test_router.py	2016-01-11 22:01:57 +0000
@@ -29,7 +29,6 @@
 from openlp.core.common import Settings, Registry
 from openlp.core.ui import ServiceManager
 from openlp.plugins.remotes.lib.httpserver import HttpRouter
-from urllib.parse import urlparse
 from tests.functional import MagicMock, patch, mock_open
 from tests.helpers.testmixin import TestMixin
 


Follow ups