mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 16:24:18 +03:00
More tests passing
This commit is contained in:
parent
d4ed178456
commit
e29a3f4cf1
|
@ -2,7 +2,7 @@
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from djangorestframework.compat import RequestFactory
|
from djangorestframework.compat import RequestFactory
|
||||||
from djangorestframework.request import RequestMixin
|
from djangorestframework.request import RequestMixin
|
||||||
from djangorestframework.parsers import FormParser, MultipartParser
|
from djangorestframework.parsers import FormParser, MultipartParser, PlainTextParser
|
||||||
#from djangorestframework.content import ContentMixin, StandardContentMixin, OverloadedContentMixin
|
#from djangorestframework.content import ContentMixin, StandardContentMixin, OverloadedContentMixin
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -43,28 +43,28 @@ class TestContentMixins(TestCase):
|
||||||
view.request = self.req.post('/', data=form_data)
|
view.request = self.req.post('/', data=form_data)
|
||||||
self.assertEqual(view.RAW_CONTENT, form_data)
|
self.assertEqual(view.RAW_CONTENT, form_data)
|
||||||
|
|
||||||
def ensure_determines_non_form_content_POST(self, mixin):
|
def ensure_determines_non_form_content_POST(self, view):
|
||||||
"""Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
|
"""Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
|
||||||
content = 'qwerty'
|
content = 'qwerty'
|
||||||
content_type = 'text/plain'
|
content_type = 'text/plain'
|
||||||
view.parsers = (PlainTextParser,)
|
view.parsers = (PlainTextParser,)
|
||||||
view.request = self.req.post('/', content, content_type=content_type)
|
view.request = self.req.post('/', content, content_type=content_type)
|
||||||
self.assertEqual(view.RAW_CONTENT, form_data)
|
self.assertEqual(view.RAW_CONTENT, content)
|
||||||
|
|
||||||
def ensure_determines_form_content_PUT(self, mixin):
|
def ensure_determines_form_content_PUT(self, view):
|
||||||
"""Ensure view.RAW_CONTENT returns content for PUT request with form content."""
|
"""Ensure view.RAW_CONTENT returns content for PUT request with form content."""
|
||||||
form_data = {'qwerty': 'uiop'}
|
form_data = {'qwerty': 'uiop'}
|
||||||
view.parsers = (FormParser, MultipartParser)
|
view.parsers = (FormParser, MultipartParser)
|
||||||
view.request = self.req.put('/', data=form_data)
|
view.request = self.req.put('/', data=form_data)
|
||||||
self.assertEqual(view.RAW_CONTENT, form_data)
|
self.assertEqual(view.RAW_CONTENT, form_data)
|
||||||
|
|
||||||
def ensure_determines_non_form_content_PUT(self, mixin):
|
def ensure_determines_non_form_content_PUT(self, view):
|
||||||
"""Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
|
"""Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
|
||||||
content = 'qwerty'
|
content = 'qwerty'
|
||||||
content_type = 'text/plain'
|
content_type = 'text/plain'
|
||||||
view.parsers = (PlainTextParser,)
|
view.parsers = (PlainTextParser,)
|
||||||
view.request = self.req.post('/', content, content_type=content_type)
|
view.request = self.req.post('/', content, content_type=content_type)
|
||||||
self.assertEqual(view.RAW_CONTENT, form_data)#
|
self.assertEqual(view.RAW_CONTENT, content)
|
||||||
|
|
||||||
def test_standard_behaviour_determines_no_content_GET(self):
|
def test_standard_behaviour_determines_no_content_GET(self):
|
||||||
"""Ensure request.RAW_CONTENT returns None for GET request with no content."""
|
"""Ensure request.RAW_CONTENT returns None for GET request with no content."""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user