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.parsers = (FormParser(), MultiPartParser())
     assert list(request.POST.items()) == list(data.items())
 def test_standard_behaviour_determines_form_content_PUT(self):
     """
     Ensure request.data returns content for PUT request with form content.
     """
     data = {'qwerty': 'uiop'}
     request = Request(factory.put('/', data))
     request.parsers = (FormParser(), MultiPartParser())
     assert list(request.data.items()) == list(data.items())
 def test_request_POST_with_files(self):
     """
     Ensure request.POST returns no content for POST request with file content.
     """
     upload = SimpleUploadedFile("file.txt", b"file_content")
     request = Request(factory.post('/', {'upload': upload}))
     request.parsers = (FormParser(), MultiPartParser())
     assert list(request.POST) == []
     assert list(request.FILES) == ['upload']
 def test_standard_behaviour_determines_non_form_content_PUT(self):
     """
     Ensure request.data returns content for PUT request with
     non-form content.
     """
     content = six.b('qwerty')
     content_type = 'text/plain'
     request = Request(factory.put('/', content, content_type=content_type))
     request.parsers = (PlainTextParser(), )
     assert request.data == content
 def test_request_DATA_with_text_content(self):
     """
     Ensure request.data returns content for POST request with
     non-form content.
     """
     content = six.b('qwerty')
     content_type = 'text/plain'
     request = Request(factory.post('/', content,
                                    content_type=content_type))
     request.parsers = (PlainTextParser(), )
     assert request.data == content