and add tests

This commit is contained in:
Tim Bentley 2015-11-08 21:07:48 +00:00
parent 1ff9413d5a
commit 97e3eea173
2 changed files with 42 additions and 0 deletions

View File

@ -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

View File

@ -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')