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
6e7e4fc0
Commit
6e7e4fc0
authored
Sep 03, 2013
by
Edmond Wong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for OPTIONS before object creation from a PUT
parent
3063a50f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
1 deletions
+45
-1
rest_framework/generics.py
+3
-1
rest_framework/tests/test_generics.py
+42
-0
No files found.
rest_framework/generics.py
View file @
6e7e4fc0
...
@@ -360,7 +360,9 @@ class GenericAPIView(views.APIView):
...
@@ -360,7 +360,9 @@ class GenericAPIView(views.APIView):
self
.
get_object
()
self
.
get_object
()
except
Http404
:
except
Http404
:
# Http404 should be acceptable and the serializer
# Http404 should be acceptable and the serializer
# metadata should be populated.
# metadata should be populated. Except this so the
# outer "else" clause of the try-except-else block
# will be executed.
pass
pass
except
(
exceptions
.
APIException
,
PermissionDenied
):
except
(
exceptions
.
APIException
,
PermissionDenied
):
pass
pass
...
...
rest_framework/tests/test_generics.py
View file @
6e7e4fc0
...
@@ -272,6 +272,48 @@ class TestInstanceView(TestCase):
...
@@ -272,6 +272,48 @@ class TestInstanceView(TestCase):
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
data
,
expected
)
self
.
assertEqual
(
response
.
data
,
expected
)
def
test_options_before_instance_create
(
self
):
"""
OPTIONS requests to RetrieveUpdateDestroyAPIView should return metadata
before the instance has been created
"""
request
=
factory
.
options
(
'/999'
)
with
self
.
assertNumQueries
(
1
):
response
=
self
.
view
(
request
,
pk
=
999
)
.
render
()
expected
=
{
'parses'
:
[
'application/json'
,
'application/x-www-form-urlencoded'
,
'multipart/form-data'
],
'renders'
:
[
'application/json'
,
'text/html'
],
'name'
:
'Instance'
,
'description'
:
'Example description for OPTIONS.'
,
'actions'
:
{
'PUT'
:
{
'text'
:
{
'max_length'
:
100
,
'read_only'
:
False
,
'required'
:
True
,
'type'
:
'string'
,
'label'
:
'Text comes here'
,
'help_text'
:
'Text description.'
},
'id'
:
{
'read_only'
:
True
,
'required'
:
False
,
'type'
:
'integer'
,
'label'
:
'ID'
,
},
}
}
}
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
data
,
expected
)
def
test_get_instance_view_incorrect_arg
(
self
):
def
test_get_instance_view_incorrect_arg
(
self
):
"""
"""
GET requests with an incorrect pk type, should raise 404, not 500.
GET requests with an incorrect pk type, should raise 404, not 500.
...
...
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