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
774298f1
Commit
774298f1
authored
Dec 03, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First pass at a test for ParseErrors breaking the browsable API
parent
c1d9a96d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
rest_framework/tests/test_renderers.py
+7
-0
No files found.
rest_framework/tests/test_renderers.py
View file @
774298f1
...
@@ -88,6 +88,7 @@ urlpatterns = patterns('',
...
@@ -88,6 +88,7 @@ urlpatterns = patterns('',
url
(
r'^cache$'
,
MockGETView
.
as_view
()),
url
(
r'^cache$'
,
MockGETView
.
as_view
()),
url
(
r'^jsonp/jsonrenderer$'
,
MockGETView
.
as_view
(
renderer_classes
=
[
JSONRenderer
,
JSONPRenderer
])),
url
(
r'^jsonp/jsonrenderer$'
,
MockGETView
.
as_view
(
renderer_classes
=
[
JSONRenderer
,
JSONPRenderer
])),
url
(
r'^jsonp/nojsonrenderer$'
,
MockGETView
.
as_view
(
renderer_classes
=
[
JSONPRenderer
])),
url
(
r'^jsonp/nojsonrenderer$'
,
MockGETView
.
as_view
(
renderer_classes
=
[
JSONPRenderer
])),
url
(
r'^parseerror$'
,
MockGETView
.
as_view
(
renderer_classes
=
[
JSONRenderer
,
BrowsableAPIRenderer
])),
url
(
r'^html$'
,
HTMLView
.
as_view
()),
url
(
r'^html$'
,
HTMLView
.
as_view
()),
url
(
r'^html1$'
,
HTMLView1
.
as_view
()),
url
(
r'^html1$'
,
HTMLView1
.
as_view
()),
url
(
r'^api'
,
include
(
'rest_framework.urls'
,
namespace
=
'rest_framework'
))
url
(
r'^api'
,
include
(
'rest_framework.urls'
,
namespace
=
'rest_framework'
))
...
@@ -219,6 +220,12 @@ class RendererEndToEndTests(TestCase):
...
@@ -219,6 +220,12 @@ class RendererEndToEndTests(TestCase):
self
.
assertEqual
(
resp
.
content
,
RENDERER_B_SERIALIZER
(
DUMMYCONTENT
))
self
.
assertEqual
(
resp
.
content
,
RENDERER_B_SERIALIZER
(
DUMMYCONTENT
))
self
.
assertEqual
(
resp
.
status_code
,
DUMMYSTATUS
)
self
.
assertEqual
(
resp
.
status_code
,
DUMMYSTATUS
)
def
test_parse_error_renderers_browsable_api
(
self
):
"""Invalid data should still render the browsable API correctly."""
resp
=
self
.
client
.
post
(
'/parseerror'
,
data
=
'foobar'
,
content_type
=
'application/json'
,
HTTP_ACCEPT
=
'text/html'
)
self
.
assertEqual
(
resp
[
'Content-Type'
],
'text/html; charset=utf-8'
)
self
.
assertContains
(
resp
.
content
,
'Mock GET View'
)
self
.
assertEqual
(
resp
.
status_code
,
status
.
HTTP_400_
)
_flat_repr
=
'{"foo": ["bar", "baz"]}'
_flat_repr
=
'{"foo": ["bar", "baz"]}'
_indented_repr
=
'{
\n
"foo": [
\n
"bar",
\n
"baz"
\n
]
\n
}'
_indented_repr
=
'{
\n
"foo": [
\n
"bar",
\n
"baz"
\n
]
\n
}'
...
...
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