diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index 802c53226..3bd207a28 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -363,6 +363,12 @@ class HttpRouter(RegistryProperties): return self._process_file(path) def _process_file(self, path): + """ + Common file processing code + + :param path: path to file to be loaded + :return: web resource to be loaded + """ content = None ext, content_type = self.get_content_type(path) file_handle = None diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 70a2033a4..7f804cbc9 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -340,3 +340,39 @@ class TestRouter(TestCase, TestMixin): # THEN: service_manager.next_item() should have been called self.assertTrue(mocked_previous_item.called, 'previous_item() should have been called in service_manager') + + def remote_stage_personal_html_test(self): + """ + Test the stage url with a parameter after loaded a url/stage.html file + """ + # GIVEN: initial route + self.router.config_dir = '' + self.router.send_response = MagicMock() + self.router.send_header = MagicMock() + self.router.end_headers = MagicMock() + self.router.wfile = MagicMock() + self.router._process_file = MagicMock() + + # WHEN: I call stage with a suffix + self.router.stages('stages', 'trb') + + # THEN: we should use the specific stage file instance + self.router._process_file.assert_called_with('trb/stage.html') + + def remote_stage_personal_css_test(self): + """ + Test the html with reference stages/trb/trb.css then loaded a stages/trb/trb.css file + """ + # GIVEN: initial route + self.router.config_dir = '' + self.router.send_response = MagicMock() + self.router.send_header = MagicMock() + self.router.end_headers = MagicMock() + self.router.wfile = MagicMock() + self.router._process_file = MagicMock() + + # WHEN: I call stage with a suffix + self.router.stages('stages', 'stages/trb/trb.css') + + # THEN: we should use the specific stage file instance + self.router._process_file.assert_called_with('trb/trb.css') \ No newline at end of file