Пример #1
0
class TestContentParsing(TestCase):
    def setUp(self):
        self.req = RequestFactory()

    def ensure_determines_no_content_GET(self, view):
        """Ensure view.DATA returns None for GET request with no content."""
        view.request = self.req.get('/')
        self.assertEqual(view.DATA, None)

    def ensure_determines_form_content_POST(self, view):
        """Ensure view.DATA returns content for POST request with form content."""
        form_data = {'qwerty': 'uiop'}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)
        self.assertEqual(view.DATA.items(), form_data.items())

    def ensure_determines_non_form_content_POST(self, view):
        """Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
        content = 'qwerty'
        content_type = 'text/plain'
        view.parsers = (PlainTextParser,)
        view.request = self.req.post('/', content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def ensure_determines_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with form content."""
        form_data = {'qwerty': 'uiop'}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.put('/', data=form_data)
        self.assertEqual(view.DATA.items(), form_data.items())

    def ensure_determines_non_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
        content = 'qwerty'
        content_type = 'text/plain'
        view.parsers = (PlainTextParser,)
        view.request = self.req.post('/', content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def test_standard_behaviour_determines_no_content_GET(self):
        """Ensure view.DATA returns None for GET request with no content."""
        self.ensure_determines_no_content_GET(RequestMixin())

    def test_standard_behaviour_determines_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with form content."""
        self.ensure_determines_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with non-form content."""
        self.ensure_determines_non_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with form content."""
        self.ensure_determines_form_content_PUT(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with non-form content."""
        self.ensure_determines_non_form_content_PUT(RequestMixin())

    def test_overloaded_behaviour_allows_content_tunnelling(self):
        """Ensure request.DATA returns content for overloaded POST request"""
        content = 'qwerty'
        content_type = 'text/plain'
        view = RequestMixin()
        form_data = {view._CONTENT_PARAM: content,
                     view._CONTENTTYPE_PARAM: content_type}
        view.request = self.req.post('/', form_data)
        view.parsers = (PlainTextParser,)
        self.assertEqual(view.DATA, content)
Пример #2
0
class TestContentParsing(TestCase):
    def setUp(self):
        self.req = RequestFactory()

    def ensure_determines_no_content_GET(self, view):
        """Ensure view.DATA returns None for GET request with no content."""
        view.request = self.req.get("/")
        self.assertEqual(view.DATA, None)

    def ensure_determines_no_content_HEAD(self, view):
        """Ensure view.DATA returns None for HEAD request."""
        view.request = self.req.head("/")
        self.assertEqual(view.DATA, None)

    def ensure_determines_form_content_POST(self, view):
        """Ensure view.DATA returns content for POST request with form content."""
        form_data = {"qwerty": "uiop"}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post("/", data=form_data)
        self.assertEqual(view.DATA.items(), form_data.items())

    def ensure_determines_non_form_content_POST(self, view):
        """Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
        content = "qwerty"
        content_type = "text/plain"
        view.parsers = (PlainTextParser,)
        view.request = self.req.post("/", content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def ensure_determines_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with form content."""
        form_data = {"qwerty": "uiop"}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.put("/", data=form_data)
        self.assertEqual(view.DATA.items(), form_data.items())

    def ensure_determines_non_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
        content = "qwerty"
        content_type = "text/plain"
        view.parsers = (PlainTextParser,)
        view.request = self.req.post("/", content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def test_standard_behaviour_determines_no_content_GET(self):
        """Ensure view.DATA returns None for GET request with no content."""
        self.ensure_determines_no_content_GET(RequestMixin())

    def test_standard_behaviour_determines_no_content_HEAD(self):
        """Ensure view.DATA returns None for HEAD request."""
        self.ensure_determines_no_content_HEAD(RequestMixin())

    def test_standard_behaviour_determines_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with form content."""
        self.ensure_determines_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with non-form content."""
        self.ensure_determines_non_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with form content."""
        self.ensure_determines_form_content_PUT(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with non-form content."""
        self.ensure_determines_non_form_content_PUT(RequestMixin())

    def test_overloaded_behaviour_allows_content_tunnelling(self):
        """Ensure request.DATA returns content for overloaded POST request"""
        content = "qwerty"
        content_type = "text/plain"
        view = RequestMixin()
        form_data = {view._CONTENT_PARAM: content, view._CONTENTTYPE_PARAM: content_type}
        view.request = self.req.post("/", form_data)
        view.parsers = (PlainTextParser,)
        self.assertEqual(view.DATA, content)

    def test_accessing_post_after_data_form(self):
        """Ensures request.POST can be accessed after request.DATA in form request"""
        form_data = {"qwerty": "uiop"}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post("/", data=form_data)

        self.assertEqual(view.DATA.items(), form_data.items())
        self.assertEqual(view.request.POST.items(), form_data.items())

    def test_accessing_post_after_data_for_json(self):
        """Ensures request.POST can be accessed after request.DATA in json request"""
        from django.utils import simplejson as json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        view.request = self.req.post("/", content, content_type=content_type)

        self.assertEqual(view.DATA.items(), data.items())
        self.assertEqual(view.request.POST.items(), [])

    def test_accessing_post_after_data_for_overloaded_json(self):
        """Ensures request.POST can be accessed after request.DATA in overloaded json request"""
        from django.utils import simplejson as json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        form_data = {view._CONTENT_PARAM: content, view._CONTENTTYPE_PARAM: content_type}

        view.request = self.req.post("/", data=form_data)

        self.assertEqual(view.DATA.items(), data.items())
        self.assertEqual(view.request.POST.items(), form_data.items())

    def test_accessing_data_after_post_form(self):
        """Ensures request.DATA can be accessed after request.POST in form request"""
        form_data = {"qwerty": "uiop"}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post("/", data=form_data)

        self.assertEqual(view.request.POST.items(), form_data.items())
        self.assertEqual(view.DATA.items(), form_data.items())

    def test_accessing_data_after_post_for_json(self):
        """Ensures request.DATA can be accessed after request.POST in json request"""
        from django.utils import simplejson as json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        view.request = self.req.post("/", content, content_type=content_type)

        post_items = view.request.POST.items()

        self.assertEqual(len(post_items), 1)
        self.assertEqual(len(post_items[0]), 2)
        self.assertEqual(post_items[0][0], content)
        self.assertEqual(view.DATA.items(), data.items())

    def test_accessing_data_after_post_for_overloaded_json(self):
        """Ensures request.DATA can be accessed after request.POST in overloaded json request"""
        from django.utils import simplejson as json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        form_data = {view._CONTENT_PARAM: content, view._CONTENTTYPE_PARAM: content_type}

        view.request = self.req.post("/", data=form_data)

        self.assertEqual(view.request.POST.items(), form_data.items())
        self.assertEqual(view.DATA.items(), data.items())
Пример #3
0
class TestContentParsing(TestCase):
    def setUp(self):
        self.req = RequestFactory()

    def ensure_determines_no_content_GET(self, view):
        """Ensure view.DATA returns None for GET request with no content."""
        view.request = self.req.get('/')
        self.assertEqual(view.DATA, None)

    def ensure_determines_no_content_HEAD(self, view):
        """Ensure view.DATA returns None for HEAD request."""
        view.request = self.req.head('/')
        self.assertEqual(view.DATA, None)

    def ensure_determines_form_content_POST(self, view):
        """Ensure view.DATA returns content for POST request with form content."""
        form_data = {'qwerty': 'uiop'}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)
        self.assertEqual(view.DATA.items(), form_data.items())

    def ensure_determines_non_form_content_POST(self, view):
        """Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
        content = 'qwerty'
        content_type = 'text/plain'
        view.parsers = (PlainTextParser,)
        view.request = self.req.post('/', content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def ensure_determines_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with form content."""
        form_data = {'qwerty': 'uiop'}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.put('/', data=form_data)
        self.assertEqual(view.DATA.items(), form_data.items())

    def ensure_determines_non_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
        content = 'qwerty'
        content_type = 'text/plain'
        view.parsers = (PlainTextParser,)
        view.request = self.req.post('/', content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def test_standard_behaviour_determines_no_content_GET(self):
        """Ensure view.DATA returns None for GET request with no content."""
        self.ensure_determines_no_content_GET(RequestMixin())

    def test_standard_behaviour_determines_no_content_HEAD(self):
        """Ensure view.DATA returns None for HEAD request."""
        self.ensure_determines_no_content_HEAD(RequestMixin())

    def test_standard_behaviour_determines_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with form content."""
        self.ensure_determines_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with non-form content."""
        self.ensure_determines_non_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with form content."""
        self.ensure_determines_form_content_PUT(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with non-form content."""
        self.ensure_determines_non_form_content_PUT(RequestMixin())

    def test_overloaded_behaviour_allows_content_tunnelling(self):
        """Ensure request.DATA returns content for overloaded POST request"""
        content = 'qwerty'
        content_type = 'text/plain'
        view = RequestMixin()
        form_data = {view._CONTENT_PARAM: content,
                     view._CONTENTTYPE_PARAM: content_type}
        view.request = self.req.post('/', form_data)
        view.parsers = (PlainTextParser,)
        self.assertEqual(view.DATA, content)
    
    def test_accessing_post_after_data_form(self):
        """Ensures request.POST can be accessed after request.DATA in form request"""
        form_data = {'qwerty': 'uiop'}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)
        
        self.assertEqual(view.DATA.items(), form_data.items())
        self.assertEqual(view.request.POST.items(), form_data.items())
    
    def test_accessing_post_after_data_for_json(self):
        """Ensures request.POST can be accessed after request.DATA in json request"""
        from django.utils import simplejson as json
        
        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'
        
        view = RequestMixin()
        view.parsers = (JSONParser,)
        
        view.request = self.req.post('/', content, content_type=content_type)
        
        self.assertEqual(view.DATA.items(), data.items())
        self.assertEqual(view.request.POST.items(), [])
    
    def test_accessing_post_after_data_for_overloaded_json(self):
        """Ensures request.POST can be accessed after request.DATA in overloaded json request"""
        from django.utils import simplejson as json
        
        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'
        
        view = RequestMixin()
        view.parsers = (JSONParser,)
        
        form_data = {view._CONTENT_PARAM: content,
                     view._CONTENTTYPE_PARAM: content_type}
        
        view.request = self.req.post('/', data=form_data)
        
        self.assertEqual(view.DATA.items(), data.items())
        self.assertEqual(view.request.POST.items(), form_data.items())
    
    def test_accessing_data_after_post_form(self):
        """Ensures request.DATA can be accessed after request.POST in form request"""
        form_data = {'qwerty': 'uiop'}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)
        
        self.assertEqual(view.request.POST.items(), form_data.items())
        self.assertEqual(view.DATA.items(), form_data.items())
    
    def test_accessing_data_after_post_for_json(self):
        """Ensures request.DATA can be accessed after request.POST in json request"""
        from django.utils import simplejson as json
        
        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'
        
        view = RequestMixin()
        view.parsers = (JSONParser,)
        
        view.request = self.req.post('/', content, content_type=content_type)
        
        post_items = view.request.POST.items()
        
        self.assertEqual(len(post_items), 1)
        self.assertEqual(len(post_items[0]), 2)
        self.assertEqual(post_items[0][0], content)
        self.assertEqual(view.DATA.items(), data.items())
    
    def test_accessing_data_after_post_for_overloaded_json(self):
        """Ensures request.DATA can be accessed after request.POST in overloaded json request"""
        from django.utils import simplejson as json
        
        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'
        
        view = RequestMixin()
        view.parsers = (JSONParser,)
        
        form_data = {view._CONTENT_PARAM: content,
                     view._CONTENTTYPE_PARAM: content_type}
        
        view.request = self.req.post('/', data=form_data)
        
        self.assertEqual(view.request.POST.items(), form_data.items())
        self.assertEqual(view.DATA.items(), data.items())
Пример #4
0
class TestContentParsing(TestCase):
    def setUp(self):
        self.req = RequestFactory()

    def ensure_determines_no_content_GET(self, view):
        """Ensure view.DATA returns None for GET request with no content."""
        view.request = self.req.get('/')
        self.assertEqual(view.DATA, None)

    def ensure_determines_no_content_HEAD(self, view):
        """Ensure view.DATA returns None for HEAD request."""
        view.request = self.req.head('/')
        self.assertEqual(view.DATA, None)

    def ensure_determines_form_content_POST(self, view):
        """Ensure view.DATA returns content for POST request with form content."""
        form_data = {'qwerty': 'uiop'}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)
        self.assertEqual(list(view.DATA.items()), list(form_data.items()))

    def ensure_determines_non_form_content_POST(self, view):
        """Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
        content = 'qwerty'
        content_type = 'text/plain'
        view.parsers = (PlainTextParser, )
        view.request = self.req.post('/', content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def ensure_determines_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with form content."""
        form_data = {'qwerty': 'uiop'}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.put(
            '/',
            data=urlencode(form_data),
            content_type='application/x-www-form-urlencoded')
        self.assertEqual(view.DATA, {'qwerty': ['uiop']})

    def ensure_determines_non_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
        content = 'qwerty'
        content_type = 'text/plain'
        view.parsers = (PlainTextParser, )
        view.request = self.req.post('/', content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def test_standard_behaviour_determines_no_content_GET(self):
        """Ensure view.DATA returns None for GET request with no content."""
        self.ensure_determines_no_content_GET(RequestMixin())

    def test_standard_behaviour_determines_no_content_HEAD(self):
        """Ensure view.DATA returns None for HEAD request."""
        self.ensure_determines_no_content_HEAD(RequestMixin())

    def test_standard_behaviour_determines_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with form content."""
        self.ensure_determines_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with non-form content."""
        self.ensure_determines_non_form_content_POST(RequestMixin())

    # def test_standard_behaviour_determines_form_content_PUT(self):
    #     """Ensure view.DATA returns content for PUT request with form content."""
    #     self.ensure_determines_form_content_PUT(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with non-form content."""
        self.ensure_determines_non_form_content_PUT(RequestMixin())

    def test_overloaded_behaviour_allows_content_tunnelling(self):
        """Ensure request.DATA returns content for overloaded POST request"""
        content = 'qwerty'
        content_type = 'text/plain'
        view = RequestMixin()
        form_data = {
            view._CONTENT_PARAM: content,
            view._CONTENTTYPE_PARAM: content_type
        }
        view.request = self.req.post('/', form_data)
        view.parsers = (PlainTextParser, )
        self.assertEqual(view.DATA, content)

    def test_accessing_post_after_data_form(self):
        """Ensures request.POST can be accessed after request.DATA in form request"""
        form_data = {'qwerty': 'uiop'}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)

        self.assertEqual(list(view.DATA.items()), list(form_data.items()))
        self.assertEqual(list(view.request.POST.items()),
                         list(form_data.items()))

    @unittest.skip('This test was disabled some time ago for some reason')
    def test_accessing_post_after_data_for_json(self):
        """Ensures request.POST can be accessed after request.DATA in json request"""
        import json

        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'

        view = RequestMixin()
        view.parsers = (JSONParser, )

        view.request = self.req.post('/', content, content_type=content_type)

        self.assertEqual(list(view.DATA.items()), list(data.items()))
        self.assertEqual(list(view.request.POST.items()), [])

    def test_accessing_post_after_data_for_overloaded_json(self):
        """Ensures request.POST can be accessed after request.DATA in overloaded json request"""
        import json

        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'

        view = RequestMixin()
        view.parsers = (JSONParser, )

        form_data = {
            view._CONTENT_PARAM: content,
            view._CONTENTTYPE_PARAM: content_type
        }

        view.request = self.req.post('/', data=form_data)

        self.assertEqual(sorted(view.DATA.items()), sorted(data.items()))
        self.assertEqual(sorted(view.request.POST.items()),
                         sorted(form_data.items()))

    def test_accessing_data_after_post_form(self):
        """Ensures request.DATA can be accessed after request.POST in form request"""
        form_data = {'qwerty': 'uiop'}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post('/', data=form_data)

        self.assertEqual(list(view.request.POST.items()),
                         list(form_data.items()))
        self.assertEqual(list(view.DATA.items()), list(form_data.items()))

    def test_accessing_data_after_post_for_json(self):
        """Ensures request.DATA can be accessed after request.POST in json request"""
        import json

        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'

        view = RequestMixin()
        view.parsers = (JSONParser, )

        view.request = self.req.post('/', content, content_type=content_type)

        self.assertEqual(list(view.DATA.items()), list(data.items()))

    def test_accessing_data_after_post_for_overloaded_json(self):
        """Ensures request.DATA can be accessed after request.POST in overloaded json request"""
        import json

        data = {'qwerty': 'uiop'}
        content = json.dumps(data)
        content_type = 'application/json'

        view = RequestMixin()
        view.parsers = (JSONParser, )

        form_data = {
            view._CONTENT_PARAM: content,
            view._CONTENTTYPE_PARAM: content_type
        }

        view.request = self.req.post('/', data=form_data)

        self.assertEqual(sorted(view.request.POST.items()),
                         sorted(form_data.items()))
        self.assertEqual(sorted(view.DATA.items()), sorted(data.items()))
Пример #5
0
class TestContentParsing(TestCase):
    def setUp(self):
        self.req = RequestFactory()

    def ensure_determines_no_content_GET(self, view):
        """Ensure view.DATA returns None for GET request with no content."""
        view.request = self.req.get("/")
        self.assertEqual(view.DATA, None)

    def ensure_determines_no_content_HEAD(self, view):
        """Ensure view.DATA returns None for HEAD request."""
        view.request = self.req.head("/")
        self.assertEqual(view.DATA, None)

    def ensure_determines_form_content_POST(self, view):
        """Ensure view.DATA returns content for POST request with form content."""
        form_data = {"qwerty": "uiop"}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post("/", data=form_data)
        self.assertEqual(list(view.DATA.items()), list(form_data.items()))

    def ensure_determines_non_form_content_POST(self, view):
        """Ensure view.RAW_CONTENT returns content for POST request with non-form content."""
        content = "qwerty"
        content_type = "text/plain"
        view.parsers = (PlainTextParser,)
        view.request = self.req.post("/", content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def ensure_determines_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with form content."""
        form_data = {"qwerty": "uiop"}
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.put("/", data=urlencode(form_data), content_type="application/x-www-form-urlencoded")
        self.assertEqual(view.DATA, {"qwerty": ["uiop"]})

    def ensure_determines_non_form_content_PUT(self, view):
        """Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
        content = "qwerty"
        content_type = "text/plain"
        view.parsers = (PlainTextParser,)
        view.request = self.req.post("/", content, content_type=content_type)
        self.assertEqual(view.DATA, content)

    def test_standard_behaviour_determines_no_content_GET(self):
        """Ensure view.DATA returns None for GET request with no content."""
        self.ensure_determines_no_content_GET(RequestMixin())

    def test_standard_behaviour_determines_no_content_HEAD(self):
        """Ensure view.DATA returns None for HEAD request."""
        self.ensure_determines_no_content_HEAD(RequestMixin())

    def test_standard_behaviour_determines_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with form content."""
        self.ensure_determines_form_content_POST(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_POST(self):
        """Ensure view.DATA returns content for POST request with non-form content."""
        self.ensure_determines_non_form_content_POST(RequestMixin())

    # def test_standard_behaviour_determines_form_content_PUT(self):
    #     """Ensure view.DATA returns content for PUT request with form content."""
    #     self.ensure_determines_form_content_PUT(RequestMixin())

    def test_standard_behaviour_determines_non_form_content_PUT(self):
        """Ensure view.DATA returns content for PUT request with non-form content."""
        self.ensure_determines_non_form_content_PUT(RequestMixin())

    def test_overloaded_behaviour_allows_content_tunnelling(self):
        """Ensure request.DATA returns content for overloaded POST request"""
        content = "qwerty"
        content_type = "text/plain"
        view = RequestMixin()
        form_data = {view._CONTENT_PARAM: content, view._CONTENTTYPE_PARAM: content_type}
        view.request = self.req.post("/", form_data)
        view.parsers = (PlainTextParser,)
        self.assertEqual(view.DATA, content)

    def test_accessing_post_after_data_form(self):
        """Ensures request.POST can be accessed after request.DATA in form request"""
        form_data = {"qwerty": "uiop"}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post("/", data=form_data)

        self.assertEqual(list(view.DATA.items()), list(form_data.items()))
        self.assertEqual(list(view.request.POST.items()), list(form_data.items()))

    @unittest.skip("This test was disabled some time ago for some reason")
    def test_accessing_post_after_data_for_json(self):
        """Ensures request.POST can be accessed after request.DATA in json request"""
        import json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        view.request = self.req.post("/", content, content_type=content_type)

        self.assertEqual(list(view.DATA.items()), list(data.items()))
        self.assertEqual(list(view.request.POST.items()), [])

    def test_accessing_post_after_data_for_overloaded_json(self):
        """Ensures request.POST can be accessed after request.DATA in overloaded json request"""
        import json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        form_data = {view._CONTENT_PARAM: content, view._CONTENTTYPE_PARAM: content_type}

        view.request = self.req.post("/", data=form_data)

        self.assertEqual(sorted(view.DATA.items()), sorted(data.items()))
        self.assertEqual(sorted(view.request.POST.items()), sorted(form_data.items()))

    def test_accessing_data_after_post_form(self):
        """Ensures request.DATA can be accessed after request.POST in form request"""
        form_data = {"qwerty": "uiop"}
        view = RequestMixin()
        view.parsers = (FormParser, MultiPartParser)
        view.request = self.req.post("/", data=form_data)

        self.assertEqual(list(view.request.POST.items()), list(form_data.items()))
        self.assertEqual(list(view.DATA.items()), list(form_data.items()))

    def test_accessing_data_after_post_for_json(self):
        """Ensures request.DATA can be accessed after request.POST in json request"""
        import json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        view.request = self.req.post("/", content, content_type=content_type)

        self.assertEqual(list(view.DATA.items()), list(data.items()))

    def test_accessing_data_after_post_for_overloaded_json(self):
        """Ensures request.DATA can be accessed after request.POST in overloaded json request"""
        import json

        data = {"qwerty": "uiop"}
        content = json.dumps(data)
        content_type = "application/json"

        view = RequestMixin()
        view.parsers = (JSONParser,)

        form_data = {view._CONTENT_PARAM: content, view._CONTENTTYPE_PARAM: content_type}

        view.request = self.req.post("/", data=form_data)

        self.assertEqual(sorted(view.request.POST.items()), sorted(form_data.items()))
        self.assertEqual(sorted(view.DATA.items()), sorted(data.items()))