]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Refactor: simplify patch test according to @bdarnell recommendations at #1090
authorTatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
Mon, 21 Jul 2014 22:28:41 +0000 (15:28 -0700)
committerTatiana Al-Chueyr <tatiana.alchueyr@gmail.com>
Mon, 21 Jul 2014 22:28:41 +0000 (15:28 -0700)
tornado/test/curl_httpclient_test.py

index 5330ca387b85ed0d16ca499406101dd58bcf82de..28a37f35b917f728c56c3b40851e9243ad68f447 100644 (file)
@@ -1,6 +1,5 @@
 from __future__ import absolute_import, division, print_function, with_statement
 
-import json
 from hashlib import md5
 
 from tornado.escape import utf8
@@ -126,32 +125,12 @@ class CurlHTTPClientTestCase(AsyncHTTPTestCase):
 
 class ContactListHandler(RequestHandler):
 
-    contact_list = {
-        "someone": {
-            "telephone": "1-800-247-9792",
-            "email": "some@email.com"
-        },
-        "another": {
-            "telephone": "1-104-132-7713",
-            "email": "other@email.com"
-        }
-    }
-
-    def get(self, contact_name):
-        data = self.contact_list.get(contact_name)
-        self.write(data)
-
     def patch(self, contact_name):
         """
         Patch implementation according to RFC-6902
         http://tools.ietf.org/html/rfc6902
         """
-        patch_data = json.loads(self.request.body)
-        for patch_item in patch_data:
-            if patch_item["op"] == "replace":
-                attribute = patch_item["path"]
-                value = patch_item["value"]
-                self.contact_list[contact_name][attribute] = value
+        self.write(self.request.body)
 
 
 @unittest.skipIf(pycurl is None, "pycurl module not present")
@@ -176,32 +155,8 @@ class NonStandardMethodCurlHTTPClientTestCase(AsyncHTTPTestCase):
         self.http_client.fetch(request, self.stop, method=None)
         return self.wait()
 
-    def test_get(self):
-        response = self.fetch("/someone", method='GET')
-        self.assertEqual(response.code, 200)
-        computed_body = json.loads(response.body)
-        expected_body = {
-            "telephone": "1-800-247-9792",
-            "email": "some@email.com"
-        }
-        self.assertEqual(computed_body, expected_body)
-
     def test_patch_with_payload(self):
-        patch_list = [
-            {
-                "op": "replace",
-                "path": "telephone",
-                "value": "55-21-99756-1934"
-            }
-        ]
-        body = json.dumps(patch_list)
-        response_patch = self.fetch("/someone", method='PATCH', body=body)
-        self.assertEqual(response_patch.code, 200)
-
-        response_get = self.fetch("/someone", method="GET")
-        computed_body = json.loads(response_get.body)
-        expected_body = {
-            "telephone": "55-21-99756-1934",
-            "email": "some@email.com"
-        }
-        self.assertEqual(computed_body, expected_body)
+       body = "some patch data"
+        response = self.fetch("/someone", method='PATCH', body=body)
+        self.assertEqual(response.code, 200)
+        self.assertEqual(response.body, body)