Exemplo n.º 1
0
 def test_exception(self):
     def client(*args):
         raise ValueError()
     proxy = proxies.Proxy(client)
     app = TestApp(proxy)
     resp = app.get('/', status='*')
     self.assertEqual(resp.status_int, 500)
Exemplo n.º 2
0
 def test_socket_timeout(self):
     def client(*args):
         raise socket.timeout()
     proxy = proxies.Proxy(client)
     app = TestApp(proxy)
     resp = app.get('/', status='*')
     self.assertEqual(resp.status_int, 504)
Exemplo n.º 3
0
    def test_proxy(self):
        environ = Request.blank('/').environ.copy()
        proxy = proxies.Proxy()
        if 'SERVER_NAME' in environ:
            del environ['SERVER_NAME']
        uri = proxy.extract_uri(environ)
        self.assertEqual(uri, 'http://localhost:80')

        environ['SERVER_NAME'] = 'foo'
        environ['SERVER_PORT'] = '8080'
        uri = proxy.extract_uri(environ)
        self.assertEqual(uri, 'http://foo:8080')

        del environ['SERVER_PORT']
        del environ['HTTP_HOST']
        environ['SERVER_NAME'] = 'foo'
        environ['wsgi.url_scheme'] = 'https'
        uri = proxy.extract_uri(environ)
        self.assertEqual(uri, 'https://foo:443')