diff options
| author | Tom Christie | 2012-10-14 22:43:07 +0100 |
|---|---|---|
| committer | Tom Christie | 2012-10-14 22:43:07 +0100 |
| commit | 551c86c43a71f7dee5cce68c5142714301f6196f (patch) | |
| tree | b9303172e27ea71b90dadf4c3a0dc303c1c0972e /rest_framework/tests/request.py | |
| parent | 7a89d7a770d310f8b72178c561fcd04e6c15e5c4 (diff) | |
| download | django-rest-framework-551c86c43a71f7dee5cce68c5142714301f6196f.tar.bz2 | |
Documentation for parsers
Diffstat (limited to 'rest_framework/tests/request.py')
| -rw-r--r-- | rest_framework/tests/request.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/rest_framework/tests/request.py b/rest_framework/tests/request.py index 7b24b036..f00ee85f 100644 --- a/rest_framework/tests/request.py +++ b/rest_framework/tests/request.py @@ -10,9 +10,9 @@ from rest_framework import status from rest_framework.authentication import SessionAuthentication from django.test.client import RequestFactory from rest_framework.parsers import ( + BaseParser, FormParser, MultiPartParser, - PlainTextParser, JSONParser ) from rest_framework.request import Request @@ -24,6 +24,19 @@ from rest_framework.views import APIView factory = RequestFactory() +class PlainTextParser(BaseParser): + media_type = 'text/plain' + + def parse_stream(self, stream, **opts): + """ + Returns a 2-tuple of `(data, files)`. + + `data` will simply be a string representing the body of the request. + `files` will always be `None`. + """ + return stream.read() + + class TestMethodOverloading(TestCase): def test_method(self): """ |
