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
2b5deefe
Commit
2b5deefe
authored
Dec 20, 2012
by
Andrew Hankinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Subclass Django's RequestFactory to provide PATCH support
parent
18338a37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
rest_framework/tests/utils.py
+27
-0
No files found.
rest_framework/tests/utils.py
0 → 100644
View file @
2b5deefe
from
django.test.client
import
RequestFactory
,
FakePayload
from
django.test.client
import
MULTIPART_CONTENT
from
urlparse
import
urlparse
class
DRFRequestFactory
(
RequestFactory
):
def
__init__
(
self
,
**
defaults
):
super
(
DRFRequestFactory
,
self
)
.
__init__
(
**
defaults
)
def
patch
(
self
,
path
,
data
=
{},
content_type
=
MULTIPART_CONTENT
,
**
extra
):
"Construct a PATCH request."
patch_data
=
self
.
_encode_data
(
data
,
content_type
)
parsed
=
urlparse
(
path
)
r
=
{
'CONTENT_LENGTH'
:
len
(
patch_data
),
'CONTENT_TYPE'
:
content_type
,
'PATH_INFO'
:
self
.
_get_path
(
parsed
),
'QUERY_STRING'
:
parsed
[
4
],
'REQUEST_METHOD'
:
'PATCH'
,
'wsgi.input'
:
FakePayload
(
patch_data
),
}
r
.
update
(
extra
)
return
self
.
request
(
**
r
)
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