← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~alisonken1/openlp/bug-1407445 into lp:openlp

 

Ken Roberts has proposed merging lp:~alisonken1/openlp/bug-1407445 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1407445 in OpenLP: "Remote API for next/previous service doesn't work"
  https://bugs.launchpad.net/openlp/+bug/1407445

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/bug-1407445/+merge/245894

bugfix 1407445

Fix remote previous/next calls to servicemananger

lp:~alisonken1/openlp/bug-1407445 (revision 2469)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/844/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/776/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/722/
[FAILURE] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/626/
Stopping after failure

passed local nosetest
passed local pep8

-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~alisonken1/openlp/bug-1407445 into lp:openlp.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2014-12-31 10:58:13 +0000
+++ openlp/core/ui/servicemanager.py	2015-01-08 18:35:24 +0000
@@ -338,6 +338,8 @@
         self.setup_ui(self)
         # Need to use event as called across threads and UI is updated
         QtCore.QObject.connect(self, QtCore.SIGNAL('servicemanager_set_item'), self.on_set_item)
+        QtCore.QObject.connect(self, QtCore.SIGNAL('servicemanager_next_item'), self.next_item)
+        QtCore.QObject.connect(self, QtCore.SIGNAL('servicemanager_previous_item'), self.previous_item)
 
     def bootstrap_post_set_up(self):
         """

=== modified file 'openlp/plugins/remotes/lib/httprouter.py'
--- openlp/plugins/remotes/lib/httprouter.py	2014-12-31 10:58:13 +0000
+++ openlp/plugins/remotes/lib/httprouter.py	2015-01-08 18:35:24 +0000
@@ -582,7 +582,7 @@
                 return self.do_http_error()
             self.service_manager.emit(QtCore.SIGNAL(event), data)
         else:
-            Registry().execute(event)
+            self.service_manager.emit(QtCore.SIGNAL(event))
         self.do_json_header()
         return json.dumps({'results': {'success': True}}).encode()
 

=== modified file 'tests/functional/openlp_plugins/remotes/test_router.py'
--- tests/functional/openlp_plugins/remotes/test_router.py	2014-12-31 10:58:13 +0000
+++ tests/functional/openlp_plugins/remotes/test_router.py	2015-01-08 18:35:24 +0000
@@ -32,8 +32,9 @@
 import os
 import urllib.request
 from unittest import TestCase
-
+from PyQt4 import QtCore
 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
@@ -61,9 +62,12 @@
         """
         Create the UI
         """
+        Registry.create()
         self.setup_application()
         self.build_settings()
         Settings().extend_default_settings(__default_settings__)
+        self.service_manager = ServiceManager()
+        self.service_manager = Registry().service_list['service_manager'] = self.service_manager
         self.router = HttpRouter()
 
     def tearDown(self):
@@ -299,3 +303,41 @@
             mocked_image_manager.assert_called_any(os.path.normpath('thumbnails\\another test'),
                                                    'slide1.png', None, '120x90')
             mocked_image_manager.assert_called_any(os.path.normpath('thumbnails\\another test'), 'slide1.png', '120x90')
+
+    def remote_next_test(self):
+        """
+        Test service manager receives remote next click properly (bug 1407445)
+        """
+        # GIVEN: initial setup and mocks
+        self.router.routes = [(r'^/api/service/(.*)$', {'function': self.router.service, 'secure': False})]
+        self.router.request_data = False
+        mocked_next_item = MagicMock()
+        self.service_manager.next_item = mocked_next_item
+        with patch.object(self.service_manager, 'setup_ui'), \
+                patch.object(self.router, 'do_json_header'):
+            self.service_manager.bootstrap_initialise()
+            self.app.processEvents()
+            # WHEN: Remote next is received
+            self.router.service(action='next')
+            self.app.processEvents()
+            # THEN: service_manager.next_item() should have been called
+            self.assertTrue(mocked_next_item.called, 'next_item() should have been called in service_manager')
+
+    def remote_previous_test(self):
+        """
+        Test service manager receives remote previous click properly (bug 1407445)
+        """
+        # GIVEN: initial setup and mocks
+        self.router.routes = [(r'^/api/service/(.*)$', {'function': self.router.service, 'secure': False})]
+        self.router.request_data = False
+        mocked_previous_item = MagicMock()
+        self.service_manager.previous_item = mocked_previous_item
+        with patch.object(self.service_manager, 'setup_ui'), \
+                patch.object(self.router, 'do_json_header'):
+            self.service_manager.bootstrap_initialise()
+            self.app.processEvents()
+            # WHEN: Remote next is received
+            self.router.service(action='previous')
+            self.app.processEvents()
+            # THEN: service_manager.next_item() should have been called
+            self.assertTrue(mocked_previous_item.called, 'previous_item() should have been called in service_manager')


Follow ups