94
94
(r'^/stage/api/poll$', {'function': mocked_function, 'secure': False}),
96
96
self.router.routes = test_route
97
self.router.command = 'GET'
98
99
# WHEN: called with a poll route
99
100
function, args = self.router.process_http_request('/stage/api/poll', None)
121
122
self.router.send_header = MagicMock()
122
123
self.router.end_headers = MagicMock()
123
124
self.router.wfile = MagicMock()
125
self.router.command = 'GET'
125
127
# WHEN: called with a poll route
126
128
self.router.do_post_processor()
211
213
self.router.send_header.assert_called_once_with('Content-type', 'text/html')
212
214
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
216
def serve_file_with_partial_params_test(self):
218
Test the serve_file method with an existing file
220
# GIVEN: mocked environment
221
self.router.send_response = MagicMock()
222
self.router.send_header = MagicMock()
223
self.router.end_headers = MagicMock()
224
self.router.wfile = MagicMock()
225
self.router.html_dir = os.path.normpath('test/dir')
226
self.router.template_vars = MagicMock()
227
with patch('openlp.core.lib.os.path.exists') as mocked_exists, \
228
patch('builtins.open', mock_open(read_data='123')):
229
mocked_exists.return_value = True
231
# WHEN: call serve_file with an existing html file
232
self.router.serve_file(os.path.normpath('test/dir/test'))
234
# THEN: it should return a 200 and the file
235
self.router.send_response.assert_called_once_with(200)
236
self.router.send_header.assert_called_once_with('Content-type', 'text/html')
237
self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
214
239
def serve_thumbnail_without_params_test(self):
216
241
Test the serve_thumbnail routine without params