diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index b3652d4df..deba92c10 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -128,7 +128,7 @@ from openlp.core.common import AppLocation, Settings, translate from openlp.core.lib import Registry, PluginStatus, StringContent, image_to_byte log = logging.getLogger(__name__) -file_types = { +FILE_TYPES = { '.html': 'text/html', '.css': 'text/css', '.js': 'application/javascript', @@ -361,8 +361,7 @@ class HttpRouter(object): try: if ext == '.html': variables = self.template_vars - content = Template(filename=path, input_encoding='utf-8', - output_encoding='utf-8').render(**variables) + content = Template(filename=path, input_encoding='utf-8', output_encoding='utf-8').render(**variables) else: file_handle = open(path, 'rb') log.debug('Opened %s' % path) @@ -386,7 +385,7 @@ class HttpRouter(object): """ content_type = 'text/plain' ext = os.path.splitext(file_name)[1] - content_type = file_types.get(ext, 'text/plain') + content_type = FILE_TYPES.get(ext, 'text/plain') return ext, content_type def poll(self): diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index 5475405a0..4d7da2b91 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -37,7 +37,8 @@ from PyQt4 import QtGui from openlp.core.common import Settings from openlp.plugins.remotes.lib.httpserver import HttpRouter -from mock import MagicMock, patch, mock_open +from tests.functional import MagicMock, patch +from mock import mock_open __default_settings__ = { 'remotes/twelve hour': True, @@ -50,6 +51,7 @@ __default_settings__ = { 'remotes/ip address': '0.0.0.0' } +TEST_PATH = os.path.abspath(os.path.dirname(__file__)) class TestRouter(TestCase): """ @@ -122,8 +124,7 @@ class TestRouter(TestCase): ['test.gif', 'image/gif'], ['test.ico', 'image/x-icon'], ['test.png', 'image/png'], ['test.whatever', 'text/plain'], ['test', 'text/plain'], ['', 'text/plain'], - ['/test/test.html', 'text/html'], - ['c:\\test\\test.html', 'text/html']] + [os.path.join(TEST_PATH,'test.html'), 'text/html']] # WHEN: calling each file type for header in headers: ext, content_type = self.router.get_content_type(header[0])