Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
94174259
Commit
94174259
authored
Apr 11, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove last bits of ParserMixin
parent
92b5a455
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
57 deletions
+5
-57
djangorestframework/parsers.py
+0
-4
djangorestframework/request.py
+1
-1
djangorestframework/resource.py
+1
-2
djangorestframework/tests/content.py
+3
-50
No files found.
djangorestframework/parsers.py
View file @
94174259
...
...
@@ -24,10 +24,6 @@ try:
except
ImportError
:
from
cgi
import
parse_qs
class
ParserMixin
(
object
):
parsers
=
()
class
BaseParser
(
object
):
...
...
djangorestframework/request.py
View file @
94174259
...
...
@@ -9,7 +9,7 @@ from django.http.multipartparser import LimitBytes
from
StringIO
import
StringIO
class
RequestMixin
(
object
):
"""
Delegate class that supplements an HttpRequest object with additional behaviour
."""
"""
Mixin behaviour to deal with requests
."""
USE_FORM_OVERLOADING
=
True
METHOD_PARAM
=
"_method"
...
...
djangorestframework/resource.py
View file @
94174259
...
...
@@ -3,7 +3,6 @@ from django.views.decorators.csrf import csrf_exempt
from
djangorestframework.compat
import
View
from
djangorestframework.emitters
import
EmitterMixin
from
djangorestframework.parsers
import
ParserMixin
from
djangorestframework.authenticators
import
AuthenticatorMixin
from
djangorestframework.validators
import
FormValidatorMixin
from
djangorestframework.response
import
Response
,
ResponseException
...
...
@@ -19,7 +18,7 @@ from djangorestframework import emitters, parsers, authenticators, status
__all__
=
[
'Resource'
]
class
Resource
(
EmitterMixin
,
ParserMixin
,
AuthenticatorMixin
,
FormValidatorMixin
,
RequestMixin
,
View
):
class
Resource
(
EmitterMixin
,
AuthenticatorMixin
,
FormValidatorMixin
,
RequestMixin
,
View
):
"""Handles incoming requests and maps them to REST operations,
performing authentication, input deserialization, input validation, output serialization."""
...
...
djangorestframework/tests/content.py
View file @
94174259
# TODO: finish off the refactoring
"""
Tests for content parsing, and form-overloaded content parsing.
"""
from
django.test
import
TestCase
from
djangorestframework.compat
import
RequestFactory
from
djangorestframework.request
import
RequestMixin
...
...
@@ -9,27 +11,6 @@ class TestContentParsing(TestCase):
def
setUp
(
self
):
self
.
req
=
RequestFactory
()
# # Interface tests
#
# def test_content_mixin_interface(self):
# """Ensure the ContentMixin interface is as expected."""
# self.assertRaises(NotImplementedError, ContentMixin().determine_content, None)
#
# def test_standard_content_mixin_interface(self):
# """Ensure the OverloadedContentMixin interface is as expected."""
# self.assertTrue(issubclass(StandardContentMixin, ContentMixin))
# getattr(StandardContentMixin, 'determine_content')
#
# def test_overloaded_content_mixin_interface(self):
# """Ensure the OverloadedContentMixin interface is as expected."""
# self.assertTrue(issubclass(OverloadedContentMixin, ContentMixin))
# getattr(OverloadedContentMixin, 'CONTENT_PARAM')
# getattr(OverloadedContentMixin, 'CONTENTTYPE_PARAM')
# getattr(OverloadedContentMixin, 'determine_content')
#
#
# # Common functionality to test with both StandardContentMixin and OverloadedContentMixin
#
def
ensure_determines_no_content_GET
(
self
,
view
):
"""Ensure view.RAW_CONTENT returns None for GET request with no content."""
view
.
request
=
self
.
req
.
get
(
'/'
)
...
...
@@ -85,28 +66,6 @@ class TestContentParsing(TestCase):
"""Ensure view.RAW_CONTENT returns content for PUT request with non-form content."""
self
.
ensure_determines_non_form_content_PUT
(
RequestMixin
())
# # OverloadedContentMixin behavioural tests
#
# def test_overloaded_behaviour_determines_no_content_GET(self):
# """Ensure StandardContentMixin.determine_content(request) returns None for GET request with no content."""
# self.ensure_determines_no_content_GET(OverloadedContentMixin())
#
# def test_overloaded_behaviour_determines_form_content_POST(self):
# """Ensure StandardContentMixin.determine_content(request) returns content for POST request with content."""
# self.ensure_determines_form_content_POST(OverloadedContentMixin())
#
# def test_overloaded_behaviour_determines_non_form_content_POST(self):
# """Ensure StandardContentMixin.determine_content(request) returns (content type, content) for POST request with content."""
# self.ensure_determines_non_form_content_POST(OverloadedContentMixin())
#
# def test_overloaded_behaviour_determines_form_content_PUT(self):
# """Ensure StandardContentMixin.determine_content(request) returns content for PUT request with content."""
# self.ensure_determines_form_content_PUT(OverloadedContentMixin())
#
# def test_overloaded_behaviour_determines_non_form_content_PUT(self):
# """Ensure StandardContentMixin.determine_content(request) returns (content type, content) for PUT request with content."""
# self.ensure_determines_non_form_content_PUT(OverloadedContentMixin())
#
def
test_overloaded_behaviour_allows_content_tunnelling
(
self
):
"""Ensure request.RAW_CONTENT returns content for overloaded POST request"""
content
=
'qwerty'
...
...
@@ -118,9 +77,3 @@ class TestContentParsing(TestCase):
view
.
parsers
=
(
PlainTextParser
,)
view
.
perform_form_overloading
()
self
.
assertEqual
(
view
.
RAW_CONTENT
,
content
)
# def test_overloaded_behaviour_allows_content_tunnelling_content_type_not_set(self):
# """Ensure determine_content(request) returns (None, content) for overloaded POST request with content type not set"""
# content = 'qwerty'
# request = self.req.post('/', {OverloadedContentMixin.CONTENT_PARAM: content})
# self.assertEqual(OverloadedContentMixin().determine_content(request), (None, content))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment