From: Ben Darnell Date: Sun, 17 Feb 2013 23:40:51 +0000 (-0500) Subject: Add a test for simple_httpclient's hostname_mapping. X-Git-Tag: v3.0.0~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=909c03363e9170401e8872153420453a80243fb9;p=thirdparty%2Ftornado.git Add a test for simple_httpclient's hostname_mapping. --- diff --git a/tornado/test/simple_httpclient_test.py b/tornado/test/simple_httpclient_test.py index 6425f1d24..a729fb5a4 100644 --- a/tornado/test/simple_httpclient_test.py +++ b/tornado/test/simple_httpclient_test.py @@ -357,3 +357,20 @@ class HTTP100ContinueTestCase(AsyncHTTPTestCase): def test_100_continue(self): res = self.fetch('/') self.assertEqual(res.body, b'A') + + +class HostnameMappingTestCase(AsyncHTTPTestCase): + def setUp(self): + super(HostnameMappingTestCase, self).setUp() + self.http_client = SimpleAsyncHTTPClient( + self.io_loop, hostname_mapping={'www.example.com': '127.0.0.1'}) + + def get_app(self): + return Application([url("/hello", HelloWorldHandler),]) + + def test_hostname_mapping(self): + self.http_client.fetch( + 'http://www.example.com:%d/hello' % self.get_http_port(), self.stop) + response = self.wait() + response.rethrow() + self.assertEqual(response.body, b'Hello world!')