Add test for request.POST

This commit is contained in:
Tom Christie 2012-09-27 12:50:18 +01:00
parent 3bae2867e9
commit fe666a14ee

View File

@ -55,7 +55,7 @@ class TestContentParsing(TestCase):
request = Request(factory.head('/')) request = Request(factory.head('/'))
self.assertEqual(request.DATA, None) self.assertEqual(request.DATA, None)
def test_standard_behaviour_determines_form_content_POST(self): def test_request_DATA_with_form_content(self):
""" """
Ensure request.DATA returns content for POST request with form content. Ensure request.DATA returns content for POST request with form content.
""" """
@ -64,7 +64,7 @@ class TestContentParsing(TestCase):
request.parser_classes = (FormParser, MultiPartParser) request.parser_classes = (FormParser, MultiPartParser)
self.assertEqual(request.DATA.items(), data.items()) self.assertEqual(request.DATA.items(), data.items())
def test_standard_behaviour_determines_non_form_content_POST(self): def test_request_DATA_with_text_content(self):
""" """
Ensure request.DATA returns content for POST request with Ensure request.DATA returns content for POST request with
non-form content. non-form content.
@ -75,6 +75,15 @@ class TestContentParsing(TestCase):
request.parser_classes = (PlainTextParser,) request.parser_classes = (PlainTextParser,)
self.assertEqual(request.DATA, content) self.assertEqual(request.DATA, content)
def test_request_POST_with_form_content(self):
"""
Ensure request.POST returns content for POST request with form content.
"""
data = {'qwerty': 'uiop'}
request = Request(factory.post('/', data))
request.parser_classes = (FormParser, MultiPartParser)
self.assertEqual(request.POST.items(), data.items())
def test_standard_behaviour_determines_form_content_PUT(self): def test_standard_behaviour_determines_form_content_PUT(self):
""" """
Ensure request.DATA returns content for PUT request with form content. Ensure request.DATA returns content for PUT request with form content.