forked from openlp/openlp
fix tests
This commit is contained in:
parent
90118af85c
commit
4f882c460b
@ -45,12 +45,28 @@ class TestHttpServer(TestCase):
|
|||||||
@patch('openlp.core.api.http.server.QtCore.QThread')
|
@patch('openlp.core.api.http.server.QtCore.QThread')
|
||||||
def test_server_start(self, mock_qthread, mock_thread):
|
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
|
# GIVEN: A new httpserver
|
||||||
# WHEN: I start the server
|
# WHEN: I start the server
|
||||||
|
Registry().set_flag('no_web_server', True)
|
||||||
HttpServer()
|
HttpServer()
|
||||||
|
|
||||||
# THEN: the api environment should have been created
|
# 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_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')
|
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')
|
||||||
|
@ -66,16 +66,32 @@ class TestWSServer(TestCase, TestMixin):
|
|||||||
@patch('openlp.core.api.websockets.QtCore.QThread')
|
@patch('openlp.core.api.websockets.QtCore.QThread')
|
||||||
def test_serverstart(self, mock_qthread, mock_worker):
|
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
|
# GIVEN: A new httpserver
|
||||||
# WHEN: I start the server
|
# WHEN: I start the server
|
||||||
|
Registry().set_flag('no_web_server', True)
|
||||||
WebSocketServer()
|
WebSocketServer()
|
||||||
|
|
||||||
# THEN: the api environment should have been created
|
# 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_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')
|
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):
|
def test_main_poll(self):
|
||||||
"""
|
"""
|
||||||
Test the main_poll function returns the correct JSON
|
Test the main_poll function returns the correct JSON
|
||||||
|
Loading…
Reference in New Issue
Block a user