aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests
diff options
context:
space:
mode:
authorTom Christie2013-06-29 08:05:08 +0100
committerTom Christie2013-06-29 08:05:08 +0100
commit90bc07f3f160485001ea329e5f69f7e521d14ec9 (patch)
treeb872a8c913e24e1138900855d602f4aeee994aa1 /rest_framework/tests
parentf585480ee10f4b5e61db4ac343b1d2af25d2de97 (diff)
downloaddjango-rest-framework-90bc07f3f160485001ea329e5f69f7e521d14ec9.tar.bz2
Addeded 'APITestClient.credentials()'
Diffstat (limited to 'rest_framework/tests')
-rw-r--r--rest_framework/tests/test_testing.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/rest_framework/tests/test_testing.py b/rest_framework/tests/test_testing.py
new file mode 100644
index 00000000..71dacd38
--- /dev/null
+++ b/rest_framework/tests/test_testing.py
@@ -0,0 +1,32 @@
+# -- coding: utf-8 --
+
+from __future__ import unicode_literals
+from django.test import TestCase
+from rest_framework.compat import patterns, url
+from rest_framework.decorators import api_view
+from rest_framework.response import Response
+from rest_framework.test import APIClient
+
+
+@api_view(['GET'])
+def mirror(request):
+ return Response({
+ 'auth': request.META.get('HTTP_AUTHORIZATION', b'')
+ })
+
+
+urlpatterns = patterns('',
+ url(r'^view/$', mirror),
+)
+
+
+class CheckTestClient(TestCase):
+ urls = 'rest_framework.tests.test_testing'
+
+ def setUp(self):
+ self.client = APIClient()
+
+ def test_credentials(self):
+ self.client.credentials(HTTP_AUTHORIZATION='example')
+ response = self.client.get('/view/')
+ self.assertEqual(response.data['auth'], 'example')