]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Move patch test to httpclient_test, according to @bdarnell recommendation
authorTatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
Mon, 21 Jul 2014 22:53:17 +0000 (15:53 -0700)
committerTatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
Mon, 21 Jul 2014 22:53:17 +0000 (15:53 -0700)
using httpclient_test.py instead of curl_httpclient_test.py so simple_httpclient_test.py is benefit from it as well
#1090

tornado/test/curl_httpclient_test.py
tornado/test/httpclient_test.py

index 28a37f35b917f728c56c3b40851e9243ad68f447..8d7065dfe34287c62f7e9e3e34d7fb07bc61854d 100644 (file)
@@ -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<contact_name>[\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)
index 124239992265fab21f0115c5ed000b362fd5d137..7dae7a799463adf5fe9c215e79307806b7ac879a 100644 (file)
@@ -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")