aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests
diff options
context:
space:
mode:
authorTom Christie2012-10-05 14:48:33 +0100
committerTom Christie2012-10-05 14:48:33 +0100
commit9d8bce8f5b0915223f57d9fe3d4b63029cfc64c2 (patch)
treea0a3f9e5a80335dcba3315f81b498e3aed241dcb /rest_framework/tests
parent3e862c77379b2f84356e2e8f0be20b7aca5b9e89 (diff)
downloaddjango-rest-framework-9d8bce8f5b0915223f57d9fe3d4b63029cfc64c2.tar.bz2
Remove Parser.can_handle_request()
Diffstat (limited to 'rest_framework/tests')
-rw-r--r--rest_framework/tests/decorators.py8
-rw-r--r--rest_framework/tests/request.py12
2 files changed, 12 insertions, 8 deletions
diff --git a/rest_framework/tests/decorators.py b/rest_framework/tests/decorators.py
index e943d8fe..a3217bd6 100644
--- a/rest_framework/tests/decorators.py
+++ b/rest_framework/tests/decorators.py
@@ -65,7 +65,9 @@ class DecoratorTestCase(TestCase):
@api_view(['GET'])
@parser_classes([JSONParser])
def view(request):
- self.assertEqual(request.parser_classes, [JSONParser])
+ self.assertEqual(len(request.parsers), 1)
+ self.assertTrue(isinstance(request.parsers[0],
+ JSONParser))
return Response({})
request = self.factory.get('/')
@@ -76,7 +78,9 @@ class DecoratorTestCase(TestCase):
@api_view(['GET'])
@authentication_classes([BasicAuthentication])
def view(request):
- self.assertEqual(request.authentication_classes, [BasicAuthentication])
+ self.assertEqual(len(request.authenticators), 1)
+ self.assertTrue(isinstance(request.authenticators[0],
+ BasicAuthentication))
return Response({})
request = self.factory.get('/')
diff --git a/rest_framework/tests/request.py b/rest_framework/tests/request.py
index 42274fcd..f5c63f11 100644
--- a/rest_framework/tests/request.py
+++ b/rest_framework/tests/request.py
@@ -61,7 +61,7 @@ class TestContentParsing(TestCase):
"""
data = {'qwerty': 'uiop'}
request = Request(factory.post('/', data))
- request.parser_classes = (FormParser, MultiPartParser)
+ request.parsers = (FormParser(), MultiPartParser())
self.assertEqual(request.DATA.items(), data.items())
def test_request_DATA_with_text_content(self):
@@ -72,7 +72,7 @@ class TestContentParsing(TestCase):
content = 'qwerty'
content_type = 'text/plain'
request = Request(factory.post('/', content, content_type=content_type))
- request.parser_classes = (PlainTextParser,)
+ request.parsers = (PlainTextParser(),)
self.assertEqual(request.DATA, content)
def test_request_POST_with_form_content(self):
@@ -81,7 +81,7 @@ class TestContentParsing(TestCase):
"""
data = {'qwerty': 'uiop'}
request = Request(factory.post('/', data))
- request.parser_classes = (FormParser, MultiPartParser)
+ request.parsers = (FormParser(), MultiPartParser())
self.assertEqual(request.POST.items(), data.items())
def test_standard_behaviour_determines_form_content_PUT(self):
@@ -99,7 +99,7 @@ class TestContentParsing(TestCase):
else:
request = Request(factory.put('/', data))
- request.parser_classes = (FormParser, MultiPartParser)
+ request.parsers = (FormParser(), MultiPartParser())
self.assertEqual(request.DATA.items(), data.items())
def test_standard_behaviour_determines_non_form_content_PUT(self):
@@ -110,7 +110,7 @@ class TestContentParsing(TestCase):
content = 'qwerty'
content_type = 'text/plain'
request = Request(factory.put('/', content, content_type=content_type))
- request.parser_classes = (PlainTextParser, )
+ request.parsers = (PlainTextParser(), )
self.assertEqual(request.DATA, content)
def test_overloaded_behaviour_allows_content_tunnelling(self):
@@ -124,7 +124,7 @@ class TestContentParsing(TestCase):
Request._CONTENTTYPE_PARAM: content_type
}
request = Request(factory.post('/', data))
- request.parser_classes = (PlainTextParser, )
+ request.parsers = (PlainTextParser(), )
self.assertEqual(request.DATA, content)
# def test_accessing_post_after_data_form(self):