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)
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',)
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")