openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #32466
[Merge] lp:~trb143/openlp/fixwebabend into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/fixwebabend into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #1735766 in OpenLP: "Launching Openlp with -w results in a traceback"
https://bugs.launchpad.net/openlp/+bug/1735766
For more details, see:
https://code.launchpad.net/~trb143/openlp/fixwebabend/+merge/334631
Fix the code and simplify
lp:~trb143/openlp/fixwebabend (revision 2795)
https://ci.openlp.io/job/Branch-01-Pull/2328/ [SUCCESS]
https://ci.openlp.io/job/Branch-02-Functional-Tests/2229/ [SUCCESS]
https://ci.openlp.io/job/Branch-03-Interface-Tests/2103/ [SUCCESS]
https://ci.openlp.io/job/Branch-04a-Code_Analysis/1429/ [SUCCESS]
https://ci.openlp.io/job/Branch-04b-Test_Coverage/1251/ [SUCCESS]
https://ci.openlp.io/job/Branch-04c-Code_Analysis2/381/ [SUCCESS]
https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/210/ [FAILURE]
Stopping after failure
Failed builds:
- Branch-05-AppVeyor-Tests #210: https://ci.openlp.io/job/Branch-05-AppVeyor-Tests/210/console
--
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/fixwebabend into lp:openlp.
=== modified file 'openlp/core/api/http/server.py'
--- openlp/core/api/http/server.py 2017-10-23 22:09:57 +0000
+++ openlp/core/api/http/server.py 2017-12-02 09:48:39 +0000
@@ -82,13 +82,14 @@
Initialise the http server, and start the http server
"""
super(HttpServer, self).__init__(parent)
- self.worker = HttpWorker()
- self.thread = QtCore.QThread()
- self.worker.moveToThread(self.thread)
- self.thread.started.connect(self.worker.run)
- self.thread.start()
- Registry().register_function('download_website', self.first_time)
- Registry().register_function('get_website_version', self.website_version)
+ if Registry().get_flag('no_web_server'):
+ self.worker = HttpWorker()
+ self.thread = QtCore.QThread()
+ self.worker.moveToThread(self.thread)
+ self.thread.started.connect(self.worker.run)
+ self.thread.start()
+ Registry().register_function('download_website', self.first_time)
+ Registry().register_function('get_website_version', self.website_version)
Registry().set_flag('website_version', '0.0')
def bootstrap_post_set_up(self):
=== modified file 'openlp/core/api/websockets.py'
--- openlp/core/api/websockets.py 2017-10-23 22:09:57 +0000
+++ openlp/core/api/websockets.py 2017-12-02 09:48:39 +0000
@@ -70,12 +70,13 @@
Initialise and start the WebSockets server
"""
super(WebSocketServer, self).__init__()
- self.settings_section = 'api'
- self.worker = WebSocketWorker(self)
- self.thread = QtCore.QThread()
- self.worker.moveToThread(self.thread)
- self.thread.started.connect(self.worker.run)
- self.thread.start()
+ if Registry().get_flag('no_web_server'):
+ self.settings_section = 'api'
+ self.worker = WebSocketWorker(self)
+ self.thread = QtCore.QThread()
+ self.worker.moveToThread(self.thread)
+ self.thread.started.connect(self.worker.run)
+ self.thread.start()
def start_server(self):
"""
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2017-11-19 21:57:38 +0000
+++ openlp/core/ui/mainwindow.py 2017-12-02 09:48:39 +0000
@@ -504,9 +504,8 @@
Settings().set_up_default_values()
self.about_form = AboutForm(self)
MediaController()
- if Registry().get_flag('no_web_server'):
- websockets.WebSocketServer()
- server.HttpServer()
+ websockets.WebSocketServer()
+ server.HttpServer()
SettingsForm(self)
self.formatting_tag_form = FormattingTagForm(self)
self.shortcut_form = ShortcutListForm(self)
=== modified file 'tests/functional/openlp_core/api/http/test_http.py'
--- tests/functional/openlp_core/api/http/test_http.py 2017-10-07 07:05:07 +0000
+++ tests/functional/openlp_core/api/http/test_http.py 2017-12-02 09:48:39 +0000
@@ -45,12 +45,28 @@
@patch('openlp.core.api.http.server.QtCore.QThread')
def test_server_start(self, mock_qthread, mock_thread):
"""
- Test the starting of the Waitress Server
+ Test the starting of the Waitress Server with the disable flag set off
"""
# GIVEN: A new httpserver
# WHEN: I start the server
+ Registry().set_flag('no_web_server', True)
HttpServer()
# THEN: the api environment should have been created
self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
self.assertEquals(1, mock_thread.call_count, 'The http thread should have been called once')
+
+ @patch('openlp.core.api.http.server.HttpWorker')
+ @patch('openlp.core.api.http.server.QtCore.QThread')
+ def test_server_start(self, mock_qthread, mock_thread):
+ """
+ Test the starting of the Waitress Server with the disable flag set off
+ """
+ # GIVEN: A new httpserver
+ # WHEN: I start the server
+ Registry().set_flag('no_web_server', False)
+ HttpServer()
+
+ # THEN: the api environment should have been created
+ self.assertEquals(0, mock_qthread.call_count, 'The qthread should not have have been called')
+ self.assertEquals(0, mock_thread.call_count, 'The http thread should not have been called')
=== modified file 'tests/functional/openlp_core/api/test_websockets.py'
--- tests/functional/openlp_core/api/test_websockets.py 2017-10-10 07:08:44 +0000
+++ tests/functional/openlp_core/api/test_websockets.py 2017-12-02 09:48:39 +0000
@@ -66,16 +66,32 @@
@patch('openlp.core.api.websockets.QtCore.QThread')
def test_serverstart(self, mock_qthread, mock_worker):
"""
- Test the starting of the WebSockets Server
+ Test the starting of the WebSockets Server with the disabled flag set on
"""
# GIVEN: A new httpserver
# WHEN: I start the server
+ Registry().set_flag('no_web_server', True)
WebSocketServer()
# THEN: the api environment should have been created
self.assertEquals(1, mock_qthread.call_count, 'The qthread should have been called once')
self.assertEquals(1, mock_worker.call_count, 'The http thread should have been called once')
+ @patch('openlp.core.api.websockets.WebSocketWorker')
+ @patch('openlp.core.api.websockets.QtCore.QThread')
+ def test_serverstart_not_required(self, mock_qthread, mock_worker):
+ """
+ Test the starting of the WebSockets Server with the disabled flag set off
+ """
+ # GIVEN: A new httpserver and the server is not required
+ # WHEN: I start the server
+ Registry().set_flag('no_web_server', False)
+ WebSocketServer()
+
+ # THEN: the api environment should have been created
+ self.assertEquals(0, mock_qthread.call_count, 'The qthread should not have been called')
+ self.assertEquals(0, mock_worker.call_count, 'The http thread should not have been called')
+
def test_main_poll(self):
"""
Test the main_poll function returns the correct JSON
=== modified file 'tests/functional/openlp_core/ui/test_mainwindow.py'
--- tests/functional/openlp_core/ui/test_mainwindow.py 2017-10-23 22:09:57 +0000
+++ tests/functional/openlp_core/ui/test_mainwindow.py 2017-12-02 09:48:39 +0000
@@ -155,7 +155,7 @@
# WHEN: you check the started functions
# THEN: the following registry functions should have been registered
- assert len(self.registry.service_list) == 12, \
+ assert len(self.registry.service_list) == 13, \
'The registry should have 12 services, got {}'.format(self.registry.service_list.keys())
assert len(self.registry.functions_list) == 19, \
'The registry should have 19 functions, got {}'.format(self.registry.functions_list.keys())
Follow ups