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
d3f65363
Commit
d3f65363
authored
Feb 15, 2013
by
Michael Elovskikh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for PATCH form in the Browsable API
parent
8fdf9250
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
rest_framework/tests/renderers.py
+4
-0
rest_framework/tests/utils.py
+14
-2
No files found.
rest_framework/tests/renderers.py
View file @
d3f65363
...
@@ -112,6 +112,9 @@ class POSTDeniedView(APIView):
...
@@ -112,6 +112,9 @@ class POSTDeniedView(APIView):
def
put
(
self
,
request
):
def
put
(
self
,
request
):
return
Response
()
return
Response
()
def
patch
(
self
,
request
):
return
Response
()
class
DocumentingRendererTests
(
TestCase
):
class
DocumentingRendererTests
(
TestCase
):
def
test_only_permitted_forms_are_displayed
(
self
):
def
test_only_permitted_forms_are_displayed
(
self
):
...
@@ -120,6 +123,7 @@ class DocumentingRendererTests(TestCase):
...
@@ -120,6 +123,7 @@ class DocumentingRendererTests(TestCase):
response
=
view
(
request
)
.
render
()
response
=
view
(
request
)
.
render
()
self
.
assertNotContains
(
response
,
'>POST<'
)
self
.
assertNotContains
(
response
,
'>POST<'
)
self
.
assertContains
(
response
,
'>PUT<'
)
self
.
assertContains
(
response
,
'>PUT<'
)
self
.
assertContains
(
response
,
'>PATCH<'
)
class
RendererEndToEndTests
(
TestCase
):
class
RendererEndToEndTests
(
TestCase
):
...
...
rest_framework/tests/utils.py
View file @
d3f65363
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.test.client
import
RequestFactory
,
FakePayload
from
django.test.client
import
FakePayload
,
Client
as
_Client
,
RequestFactory
as
_RequestFactory
from
django.test.client
import
MULTIPART_CONTENT
from
django.test.client
import
MULTIPART_CONTENT
from
rest_framework.compat
import
urlparse
from
rest_framework.compat
import
urlparse
class
RequestFactory
(
RequestFactory
):
class
RequestFactory
(
_
RequestFactory
):
def
__init__
(
self
,
**
defaults
):
def
__init__
(
self
,
**
defaults
):
super
(
RequestFactory
,
self
)
.
__init__
(
**
defaults
)
super
(
RequestFactory
,
self
)
.
__init__
(
**
defaults
)
...
@@ -26,3 +26,15 @@ class RequestFactory(RequestFactory):
...
@@ -26,3 +26,15 @@ class RequestFactory(RequestFactory):
}
}
r
.
update
(
extra
)
r
.
update
(
extra
)
return
self
.
request
(
**
r
)
return
self
.
request
(
**
r
)
class
Client
(
_Client
,
RequestFactory
):
def
patch
(
self
,
path
,
data
=
{},
content_type
=
MULTIPART_CONTENT
,
follow
=
False
,
**
extra
):
"""
Send a resource to the server using PATCH.
"""
response
=
super
(
Client
,
self
)
.
patch
(
path
,
data
=
data
,
content_type
=
content_type
,
**
extra
)
if
follow
:
response
=
self
.
_handle_redirects
(
response
,
**
extra
)
return
response
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