예제 #1
0
from gi.repository import GObject
from wsgiref.simple_server import WSGIRequestHandler
from wsgiref.simple_server import make_server

from rhythmweb.app import app
from rhythmweb.conf import Configuration

import logging
log = logging.getLogger(__name__)

base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
default_resource = os.path.join(base_path, 'resources/default')
touch_resource = os.path.join(base_path, 'resources/touch')

app.mount(default_resource, 'default', ignore=default_resource)
app.mount(touch_resource, 'mobile', ignore=touch_resource)

match_mobile = re.compile(r'.*?(Android|iPhone).*?')

CONTENT_TYPES = {
    'css': 'text/css',
    'htm': 'text/html',
    'html': 'text/html',
    'gif': 'image/gif',
    'png': 'image/png',
    'jpg': 'image/jpeg',
    'jpeg': 'image/jpeg',
    'ico': 'image/ico',
    'svg': 'image/svg+xml',
    'js': 'application/x-javascript',
예제 #2
0
 def test_mount_invalid_path_raises_exception(self):
     with self.assertRaises(IOError):
         app.mount('./testXXXX', 'other3', ignore='/test')
예제 #3
0
 def test_mount_path_finds_file(self):
     app.mount('./test', 'other', ignore='/test')
     f = app.get_file('/bootstrap.sh', 'other')
     self.assertFalse(len(f) == 0)
예제 #4
0
 def test_get_invalid_file_returns_none(self):
     app.mount('./test', 'other2', ignore='/test')
     f = app.get_file('/invalid_file.sh', 'other2')
     self.assertIsNone(f)
예제 #5
0
 def test_mount_file_finds_file(self):
     app.mount('./test/acceptance.sh', 'default')
     f = app.get_file('/test/acceptance.sh', 'default')
     self.assertFalse(len(f) == 0)