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
91b3fb0b
Commit
91b3fb0b
authored
Sep 27, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove RequestFactory from compat (Now 1.2 is not supported)
parent
ec3c0c28
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
7 additions
and
53 deletions
+7
-53
rest_framework/compat.py
+0
-46
rest_framework/tests/decorators.py
+1
-1
rest_framework/tests/files.py
+1
-1
rest_framework/tests/mixins.py
+1
-1
rest_framework/tests/parsers.py
+2
-2
rest_framework/tests/request.py
+1
-1
rest_framework/tests/throttling.py
+1
-1
No files found.
rest_framework/compat.py
View file @
91b3fb0b
...
@@ -19,52 +19,6 @@ except ImportError:
...
@@ -19,52 +19,6 @@ except ImportError:
from
cgi
import
parse_qs
from
cgi
import
parse_qs
# django.test.client.RequestFactory (Required for Django < 1.3)
try
:
from
django.test.client
import
RequestFactory
except
ImportError
:
from
django.test
import
Client
from
django.core.handlers.wsgi
import
WSGIRequest
# From: http://djangosnippets.org/snippets/963/
# Lovely stuff
class
RequestFactory
(
Client
):
"""
Class that lets you create mock :obj:`Request` objects for use in testing.
Usage::
rf = RequestFactory()
get_request = rf.get('/hello/')
post_request = rf.post('/submit/', {'foo': 'bar'})
This class re-uses the :class:`django.test.client.Client` interface. Of which
you can find the docs here__.
__ http://www.djangoproject.com/documentation/testing/#the-test-client
Once you have a `request` object you can pass it to any :func:`view` function,
just as if that :func:`view` had been hooked up using a URLconf.
"""
def
request
(
self
,
**
request
):
"""
Similar to parent class, but returns the :obj:`request` object as soon as it
has created it.
"""
environ
=
{
'HTTP_COOKIE'
:
self
.
cookies
,
'PATH_INFO'
:
'/'
,
'QUERY_STRING'
:
''
,
'REQUEST_METHOD'
:
'GET'
,
'SCRIPT_NAME'
:
''
,
'SERVER_NAME'
:
'testserver'
,
'SERVER_PORT'
:
80
,
'SERVER_PROTOCOL'
:
'HTTP/1.1'
,
}
environ
.
update
(
self
.
defaults
)
environ
.
update
(
request
)
return
WSGIRequest
(
environ
)
# django.views.generic.View (Django >= 1.3)
# django.views.generic.View (Django >= 1.3)
try
:
try
:
from
django.views.generic
import
View
from
django.views.generic
import
View
...
...
rest_framework/tests/decorators.py
View file @
91b3fb0b
from
django.test
import
TestCase
from
django.test
import
TestCase
from
rest_framework
import
status
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.compa
t
import
RequestFactory
from
django.test.clien
t
import
RequestFactory
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.parsers
import
JSONParser
from
rest_framework.parsers
import
JSONParser
from
rest_framework.authentication
import
BasicAuthentication
from
rest_framework.authentication
import
BasicAuthentication
...
...
rest_framework/tests/files.py
View file @
91b3fb0b
# from django.test import TestCase
# from django.test import TestCase
# from django import forms
# from django import forms
# from
rest_framework.compa
t import RequestFactory
# from
django.test.clien
t import RequestFactory
# from rest_framework.views import View
# from rest_framework.views import View
# from rest_framework.response import Response
# from rest_framework.response import Response
...
...
rest_framework/tests/mixins.py
View file @
91b3fb0b
# """Tests for the mixin module"""
# """Tests for the mixin module"""
# from django.test import TestCase
# from django.test import TestCase
# from rest_framework import status
# from rest_framework import status
# from
rest_framework.compa
t import RequestFactory
# from
django.test.clien
t import RequestFactory
# from django.contrib.auth.models import Group, User
# from django.contrib.auth.models import Group, User
# from rest_framework.mixins import CreateModelMixin, PaginatorMixin, ReadModelMixin
# from rest_framework.mixins import CreateModelMixin, PaginatorMixin, ReadModelMixin
# from rest_framework.resources import ModelResource
# from rest_framework.resources import ModelResource
...
...
rest_framework/tests/parsers.py
View file @
91b3fb0b
# """
# """
# ..
# ..
# >>> from rest_framework.parsers import FormParser
# >>> from rest_framework.parsers import FormParser
# >>> from
rest_framework.compa
t import RequestFactory
# >>> from
django.test.clien
t import RequestFactory
# >>> from rest_framework.views import View
# >>> from rest_framework.views import View
# >>> from StringIO import StringIO
# >>> from StringIO import StringIO
# >>> from urllib import urlencode
# >>> from urllib import urlencode
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
# import httplib, mimetypes
# import httplib, mimetypes
# from tempfile import TemporaryFile
# from tempfile import TemporaryFile
# from django.test import TestCase
# from django.test import TestCase
# from
rest_framework.compa
t import RequestFactory
# from
django.test.clien
t import RequestFactory
# from rest_framework.parsers import MultiPartParser
# from rest_framework.parsers import MultiPartParser
# from rest_framework.views import View
# from rest_framework.views import View
# from StringIO import StringIO
# from StringIO import StringIO
...
...
rest_framework/tests/request.py
View file @
91b3fb0b
...
@@ -7,7 +7,7 @@ from django.test import TestCase, Client
...
@@ -7,7 +7,7 @@ from django.test import TestCase, Client
from
rest_framework
import
status
from
rest_framework
import
status
from
rest_framework.authentication
import
SessionAuthentication
from
rest_framework.authentication
import
SessionAuthentication
from
rest_framework.compa
t
import
RequestFactory
from
django.test.clien
t
import
RequestFactory
from
rest_framework.parsers
import
(
from
rest_framework.parsers
import
(
FormParser
,
FormParser
,
MultiPartParser
,
MultiPartParser
,
...
...
rest_framework/tests/throttling.py
View file @
91b3fb0b
...
@@ -6,7 +6,7 @@ from django.test import TestCase
...
@@ -6,7 +6,7 @@ from django.test import TestCase
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.core.cache
import
cache
from
django.core.cache
import
cache
from
rest_framework.compa
t
import
RequestFactory
from
django.test.clien
t
import
RequestFactory
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
rest_framework.throttling
import
UserRateThrottle
from
rest_framework.throttling
import
UserRateThrottle
from
rest_framework.response
import
Response
from
rest_framework.response
import
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