mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 19:14:01 +03:00
Added tests for PATCH form in the Browsable API
This commit is contained in:
parent
8fdf925015
commit
d3f6536365
|
@ -112,6 +112,9 @@ class POSTDeniedView(APIView):
|
||||||
def put(self, request):
|
def put(self, request):
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
|
def patch(self, request):
|
||||||
|
return Response()
|
||||||
|
|
||||||
|
|
||||||
class DocumentingRendererTests(TestCase):
|
class DocumentingRendererTests(TestCase):
|
||||||
def test_only_permitted_forms_are_displayed(self):
|
def test_only_permitted_forms_are_displayed(self):
|
||||||
|
@ -120,6 +123,7 @@ class DocumentingRendererTests(TestCase):
|
||||||
response = view(request).render()
|
response = view(request).render()
|
||||||
self.assertNotContains(response, '>POST<')
|
self.assertNotContains(response, '>POST<')
|
||||||
self.assertContains(response, '>PUT<')
|
self.assertContains(response, '>PUT<')
|
||||||
|
self.assertContains(response, '>PATCH<')
|
||||||
|
|
||||||
|
|
||||||
class RendererEndToEndTests(TestCase):
|
class RendererEndToEndTests(TestCase):
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.test.client import RequestFactory, FakePayload
|
from django.test.client import FakePayload, Client as _Client, RequestFactory as _RequestFactory
|
||||||
from django.test.client import MULTIPART_CONTENT
|
from django.test.client import MULTIPART_CONTENT
|
||||||
from rest_framework.compat import urlparse
|
from rest_framework.compat import urlparse
|
||||||
|
|
||||||
|
|
||||||
class RequestFactory(RequestFactory):
|
class RequestFactory(_RequestFactory):
|
||||||
|
|
||||||
def __init__(self, **defaults):
|
def __init__(self, **defaults):
|
||||||
super(RequestFactory, self).__init__(**defaults)
|
super(RequestFactory, self).__init__(**defaults)
|
||||||
|
@ -26,3 +26,15 @@ class RequestFactory(RequestFactory):
|
||||||
}
|
}
|
||||||
r.update(extra)
|
r.update(extra)
|
||||||
return self.request(**r)
|
return self.request(**r)
|
||||||
|
|
||||||
|
|
||||||
|
class Client(_Client, RequestFactory):
|
||||||
|
def patch(self, path, data={}, content_type=MULTIPART_CONTENT,
|
||||||
|
follow=False, **extra):
|
||||||
|
"""
|
||||||
|
Send a resource to the server using PATCH.
|
||||||
|
"""
|
||||||
|
response = super(Client, self).patch(path, data=data, content_type=content_type, **extra)
|
||||||
|
if follow:
|
||||||
|
response = self._handle_redirects(response, **extra)
|
||||||
|
return response
|
||||||
|
|
Loading…
Reference in New Issue
Block a user