Exemple #1
0
    def test_wsgi_file_wrapper(self):
        class DummyWrapper(object):
            def __init__(self, file, block_size):
                self.file = file
                self.block_size = block_size

        environ = {
            'wsgi.url_scheme': 'http',
            'wsgi.version': (1, 0),
            'wsgi.file_wrapper': DummyWrapper,
            'SERVER_NAME': 'somedomain.com',
            'SERVER_PORT': '8080',
            'PATH_INFO': '/index.html',
            'SCRIPT_NAME': '',
            'REQUEST_METHOD': 'GET',
        }

        app = FileServeApp('./tests/test.html', 3600)
        app_iter = Request(environ).send(app).app_iter
        assert isinstance(app_iter, DummyWrapper)
        assert b'Welcome to TurboGears 2.0' in app_iter.file.read()
        app_iter.file.close()
Exemple #2
0
 def test_FileApp_non_existing_file(self):
     fa = TestApp(FileServeApp('this_does_not_exists.unknown', 0))
     r = fa.get('/', status=403)
     assert '403' in r