aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/utils.py
diff options
context:
space:
mode:
authorTom Christie2013-02-22 00:42:37 -0800
committerTom Christie2013-02-22 00:42:37 -0800
commitef3303eb3702f365aeecb8296592cffa93c4afc7 (patch)
treebc6297fb5bb590558dd312d976eb5225eb2f9119 /rest_framework/tests/utils.py
parent47a4f0863d08e4b839ea3bbd7308ecc0f995b7d9 (diff)
parent31f3fa63b2758d1e16f6814f4ac18647412bdddb (diff)
downloaddjango-rest-framework-ef3303eb3702f365aeecb8296592cffa93c4afc7.tar.bz2
Merge pull request #670 from tomchristie/generic-form-input
PUT or PATCH raw data (eg. json) from Browseable 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