More tests passing

This commit is contained in:
Tom Christie 2011-04-11 11:56:07 +01:00
parent d4ed178456
commit e29a3f4cf1

View File

@ -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."""