Fixed OS specific string

Coding standard fixes
This commit is contained in:
Felipe Polo-Wood 2013-11-14 15:33:46 -05:00
parent 649494589a
commit e56414e22c
2 changed files with 7 additions and 7 deletions

View File

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

View File

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