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
5bb66803
Commit
5bb66803
authored
Oct 28, 2012
by
Marko Tibold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_put_as_create_on_id_based_url should check for a created-response.
parent
bc99142c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
rest_framework/tests/generics.py
+6
-10
No files found.
rest_framework/tests/generics.py
View file @
5bb66803
...
@@ -235,20 +235,16 @@ class TestInstanceView(TestCase):
...
@@ -235,20 +235,16 @@ class TestInstanceView(TestCase):
def
test_put_as_create_on_id_based_url
(
self
):
def
test_put_as_create_on_id_based_url
(
self
):
"""
"""
PUT requests to RetrieveUpdateDestroyAPIView should create an object
PUT requests to RetrieveUpdateDestroyAPIView should create an object
at the requested url if it doesn't exist, if creation is not possible,
at the requested url if it doesn't exist.
e.g. the pk for an id-field is determined by the database,
a HTTP_403_FORBIDDEN error-response must be returned.
"""
"""
content
=
{
'text'
:
'foobar'
}
content
=
{
'text'
:
'foobar'
}
# pk fields can not be created on demand, only the database can set th pk for a new object
# pk fields can not be created on demand, only the database can set th pk for a new object
request
=
factory
.
put
(
'/5'
,
json
.
dumps
(
content
),
request
=
factory
.
put
(
'/5'
,
json
.
dumps
(
content
),
content_type
=
'application/json'
)
content_type
=
'application/json'
)
response
=
self
.
view
(
request
,
pk
=
5
)
.
render
()
response
=
self
.
view
(
request
,
pk
=
5
)
.
render
()
expected
=
{
self
.
assertEquals
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
'detail'
:
u'A resource could not be created at the requested URI'
new_obj
=
self
.
objects
.
get
(
slug
=
'test_slug'
)
}
self
.
assertEquals
(
new_obj
.
text
,
'foobar'
)
self
.
assertEquals
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertEquals
(
response
.
data
,
expected
)
def
test_put_as_create_on_slug_based_url
(
self
):
def
test_put_as_create_on_slug_based_url
(
self
):
"""
"""
...
@@ -261,8 +257,8 @@ class TestInstanceView(TestCase):
...
@@ -261,8 +257,8 @@ class TestInstanceView(TestCase):
response
=
self
.
slug_based_view
(
request
,
pk
=
'test_slug'
)
.
render
()
response
=
self
.
slug_based_view
(
request
,
pk
=
'test_slug'
)
.
render
()
self
.
assertEquals
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertEquals
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertEquals
(
response
.
data
,
{
'slug'
:
'test_slug'
,
'text'
:
'foobar'
})
self
.
assertEquals
(
response
.
data
,
{
'slug'
:
'test_slug'
,
'text'
:
'foobar'
})
updated
=
self
.
objects
.
get
(
slug
=
'test_slug'
)
new_obj
=
self
.
objects
.
get
(
slug
=
'test_slug'
)
self
.
assertEquals
(
updated
.
text
,
'foobar'
)
self
.
assertEquals
(
new_obj
.
text
,
'foobar'
)
# Regression test for #285
# Regression test for #285
...
...
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