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
a53101be
Commit
a53101be
authored
Jul 15, 2011
by
Tom Drummond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More tests for overloaded json requests and normal json requests
parent
7e2e3cbf
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
2 deletions
+38
-2
djangorestframework/tests/content.py
+38
-2
No files found.
djangorestframework/tests/content.py
View file @
a53101be
...
...
@@ -114,7 +114,7 @@ class TestContentParsing(TestCase):
self
.
assertEqual
(
view
.
DATA
.
items
(),
form_data
.
items
())
self
.
assertEqual
(
view
.
request
.
POST
.
items
(),
form_data
.
items
())
def
test_
empty
_post_after_data_for_json
(
self
):
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
...
...
@@ -125,6 +125,22 @@ class TestContentParsing(TestCase):
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
}
...
...
@@ -143,7 +159,7 @@ class TestContentParsing(TestCase):
self
.
assertEqual
(
view
.
request
.
POST
.
items
(),
form_data
.
items
())
self
.
assertEqual
(
view
.
DATA
.
items
(),
form_data
.
items
())
def
test_accessing_data_after_post_json
(
self
):
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
...
...
@@ -154,6 +170,26 @@ class TestContentParsing(TestCase):
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
}
...
...
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