def test_no_content(self): http_client = Client(recorder=DebugPrintRecorder()) proxy = HTTPProxyServer(http_client, io_loop=self.io_loop) proxy_socket, proxy_port = tornado.testing.bind_unused_port() proxy.add_socket(proxy_socket) _logger.debug('Proxy on port {0}'.format(proxy_port)) test_client = tornado.curl_httpclient.CurlAsyncHTTPClient() request = tornado.httpclient.HTTPRequest( self.get_url('/no_content'), proxy_host='localhost', proxy_port=proxy_port ) response = yield test_client.fetch(request) self.assertEqual(204, response.code)
def test_client(self): http_client = Client() proxy_server = HTTPProxyServer(http_client) proxy_socket, proxy_host = tornado.testing.bind_unused_port() proxy_server.add_socket(proxy_socket) remote_client = PhantomJSClient('localhost:{0}'.format(proxy_host)) with remote_client.remote() as remote: self.assertIn(remote, remote_client.remotes_busy) test_remote = remote for dummy in range(100): if test_remote in remote_client.remotes_ready: break yield wpull.async.sleep(0.1) self.assertIn(test_remote, remote_client.remotes_ready) self.assertNotIn(test_remote, remote_client.remotes_busy)
def test_client(self): http_client = Client() proxy_server = HTTPProxyServer(http_client) proxy_socket, proxy_host = tornado.testing.bind_unused_port() proxy_server.add_socket(proxy_socket) remote_client = PhantomJSClient('localhost:{0}'.format(proxy_host)) with remote_client.remote() as remote: self.assertIn(remote, remote_client.remotes_busy) test_remote = remote for dummy in range(100): if test_remote in remote_client.remotes_ready: break yield wpull. async .sleep(0.1) self.assertIn(test_remote, remote_client.remotes_ready) self.assertNotIn(test_remote, remote_client.remotes_busy)
def test_post(self): http_client = Client(recorder=DebugPrintRecorder()) proxy = HTTPProxyServer(http_client, io_loop=self.io_loop) proxy_socket, proxy_port = tornado.testing.bind_unused_port() proxy.add_socket(proxy_socket) _logger.debug('Proxy on port {0}'.format(proxy_port)) test_client = tornado.curl_httpclient.CurlAsyncHTTPClient() request = tornado.httpclient.HTTPRequest( self.get_url('/post/'), proxy_host='localhost', proxy_port=proxy_port, body='text=blah', method='POST' ) response = yield test_client.fetch(request) self.assertEqual(200, response.code) self.assertIn(b'OK', response.body)