aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/utils.py
diff options
context:
space:
mode:
authorMichael Elovskikh2013-02-15 15:33:36 +0600
committerMichael Elovskikh2013-02-15 15:44:11 +0600
commitd3f6536365cefa01f93cfadcc5e6a737d5c5fa80 (patch)
tree7c904d954e70f9b72ccf57963ee659c93d2d838e /rest_framework/tests/utils.py
parent8fdf9250157cde2341ec9c86ead44b2ed1354aa2 (diff)
downloaddjango-rest-framework-d3f6536365cefa01f93cfadcc5e6a737d5c5fa80.tar.bz2
Added tests for PATCH form in the Browsable API
Diffstat (limited to 'rest_framework/tests/utils.py')
-rw-r--r--rest_framework/tests/utils.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/rest_framework/tests/utils.py b/rest_framework/tests/utils.py
index 224c4f9d..8c87917d 100644
--- a/rest_framework/tests/utils.py
+++ b/rest_framework/tests/utils.py
@@ -1,10 +1,10 @@
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 rest_framework.compat import urlparse
-class RequestFactory(RequestFactory):
+class RequestFactory(_RequestFactory):
def __init__(self, **defaults):
super(RequestFactory, self).__init__(**defaults)
@@ -26,3 +26,15 @@ class RequestFactory(RequestFactory):
}
r.update(extra)
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