From: Tatiana Al-Chueyr Date: Mon, 21 Jul 2014 22:53:17 +0000 (-0700) Subject: Move patch test to httpclient_test, according to @bdarnell recommendation X-Git-Tag: v4.1.0b1~123^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3573f2a63681c2a576b53258f0765062739945e7;p=thirdparty%2Ftornado.git Move patch test to httpclient_test, according to @bdarnell recommendation using httpclient_test.py instead of curl_httpclient_test.py so simple_httpclient_test.py is benefit from it as well #1090 --- diff --git a/tornado/test/curl_httpclient_test.py b/tornado/test/curl_httpclient_test.py index 28a37f35b..8d7065dfe 100644 --- a/tornado/test/curl_httpclient_test.py +++ b/tornado/test/curl_httpclient_test.py @@ -121,42 +121,3 @@ class CurlHTTPClientTestCase(AsyncHTTPTestCase): def test_fail_custom_reason(self): response = self.fetch('/custom_fail_reason') self.assertEqual(str(response.error), "HTTP 400: Custom reason") - - -class ContactListHandler(RequestHandler): - - def patch(self, contact_name): - """ - Patch implementation according to RFC-6902 - http://tools.ietf.org/html/rfc6902 - """ - self.write(self.request.body) - - -@unittest.skipIf(pycurl is None, "pycurl module not present") -class NonStandardMethodCurlHTTPClientTestCase(AsyncHTTPTestCase): - - def setUp(self): - super(NonStandardMethodCurlHTTPClientTestCase, self).setUp() - self.http_client = CurlAsyncHTTPClient(self.io_loop, - defaults=dict(allow_ipv6=False)) - - def get_app(self): - return Application([ - ('/(?P[\w\-]+)', ContactListHandler), - ]) - - def fetch(self, path, body=None, **kwargs): - kwargs['url'] = self.get_url(path) - request = HTTPRequest(**kwargs) - if body is not None: - request.body = body - request.allow_nonstandard_methods = True - self.http_client.fetch(request, self.stop, method=None) - return self.wait() - - def test_patch_with_payload(self): - body = "some patch data" - response = self.fetch("/someone", method='PATCH', body=body) - self.assertEqual(response.code, 200) - self.assertEqual(response.body, body) diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 124239992..7dae7a799 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -91,6 +91,16 @@ class ContentLength304Handler(RequestHandler): pass +class PatchHandler(RequestHandler): + + def patch(self): + """ + Patch implementation according to RFC-6902 + http://tools.ietf.org/html/rfc6902 + """ + self.write(self.request.body) + + class AllMethodsHandler(RequestHandler): SUPPORTED_METHODS = RequestHandler.SUPPORTED_METHODS + ('OTHER',) @@ -118,8 +128,24 @@ class HTTPClientCommonTestCase(AsyncHTTPTestCase): url("/user_agent", UserAgentHandler), url("/304_with_content_length", ContentLength304Handler), url("/all_methods", AllMethodsHandler), + url('/patch', PatchHandler), ], gzip=True) + def fetch(self, path, body=None, **kwargs): + kwargs['url'] = self.get_url(path) + request = HTTPRequest(**kwargs) + if body is not None: + request.body = body + request.allow_nonstandard_methods = True + self.http_client.fetch(request, self.stop, method=None) + return self.wait() + + def test_patch_receives_payload(self): + body = "some patch data" + response = self.fetch("/patch", method='PATCH', body=body) + self.assertEqual(response.code, 200) + self.assertEqual(response.body, body) + @skipOnTravis def test_hello_world(self): response = self.fetch("/hello")