Ticket #17797: django-test-client-PATCH-tests.patch

File django-test-client-PATCH-tests.patch, 1.5 KB (added by pfarmer, 13 years ago)

Basic testing for client.patch.

  • tests/regressiontests/test_client_regress/models.py

     
    796796        self.assertEqual(response.status_code, 200)
    797797        self.assertEqual(response.content, 'request method: DELETE')
    798798
     799    def test_patch(self):
     800        "Request a view via request method PATCH"
     801        response = self.client.patch('/test_client_regress/request_methods/')
     802        self.assertEqual(response.status_code, 200)
     803        self.assertEqual(response.content, 'request method: PATCH')
     804
     805
    799806class RequestMethodStringDataTests(TestCase):
    800807    def test_post(self):
    801808        "Request a view with string data via request method POST"
     
    813820        self.assertEqual(response.status_code, 200)
    814821        self.assertEqual(response.content, 'request method: PUT')
    815822
     823    def test_patch(self):
     824        "Request a view with string data via request method PATCH"
     825        # Regression test for #11371
     826        data = u'{"test": "json"}'
     827        response = self.client.patch('/test_client_regress/request_methods/', data=data, content_type='application/json')
     828        self.assertEqual(response.status_code, 200)
     829        self.assertEqual(response.content, 'request method: PATCH')
     830
     831
    816832class QueryStringTests(TestCase):
    817833    def test_get_like_requests(self):
    818834        # See: https://code.djangoproject.com/ticket/10571.
Back to Top