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
7351a3f6
Commit
7351a3f6
authored
Jun 25, 2015
by
José Padilla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sort imports with isort
parent
83c9136c
Hide whitespace changes
Inline
Side-by-side
Showing
82 changed files
with
345 additions
and
268 deletions
+345
-268
rest_framework/authentication.py
+2
-2
rest_framework/authtoken/migrations/0001_initial.py
+1
-1
rest_framework/authtoken/models.py
+2
-3
rest_framework/authtoken/views.py
+2
-2
rest_framework/compat.py
+3
-3
rest_framework/exceptions.py
+2
-1
rest_framework/fields.py
+16
-17
rest_framework/filters.py
+3
-4
rest_framework/generics.py
+2
-2
rest_framework/metadata.py
+1
-1
rest_framework/negotiation.py
+1
-1
rest_framework/pagination.py
+7
-8
rest_framework/parsers.py
+7
-6
rest_framework/permissions.py
+0
-1
rest_framework/relations.py
+9
-9
rest_framework/renderers.py
+10
-10
rest_framework/request.py
+2
-2
rest_framework/response.py
+1
-1
rest_framework/reverse.py
+2
-1
rest_framework/routers.py
+3
-4
rest_framework/serializers.py
+10
-14
rest_framework/settings.py
+1
-2
rest_framework/templatetags/rest_framework.py
+4
-6
rest_framework/test.py
+5
-5
rest_framework/urlpatterns.py
+1
-1
rest_framework/urls.py
+0
-1
rest_framework/utils/breadcrumbs.py
+1
-1
rest_framework/utils/encoders.py
+5
-5
rest_framework/utils/field_mapping.py
+1
-2
rest_framework/utils/model_meta.py
+2
-3
rest_framework/utils/representation.py
+1
-1
rest_framework/versioning.py
+2
-2
rest_framework/views.py
+6
-6
rest_framework/viewsets.py
+1
-1
setup.py
+2
-1
tests/browsable_api/auth_urls.py
+2
-2
tests/browsable_api/no_auth_urls.py
+1
-0
tests/browsable_api/test_browsable_api.py
+1
-0
tests/browsable_api/views.py
+2
-3
tests/description.py
+0
-1
tests/test_atomic_requests.py
+2
-2
tests/test_authentication.py
+12
-13
tests/test_decorators.py
+7
-9
tests/test_description.py
+7
-2
tests/test_fields.py
+7
-5
tests/test_filters.py
+6
-3
tests/test_generics.py
+5
-2
tests/test_htmlrenderer.py
+5
-3
tests/test_metadata.py
+7
-3
tests/test_middleware.py
+1
-1
tests/test_model_serializer.py
+8
-3
tests/test_multitable_inheritance.py
+2
-0
tests/test_negotiation.py
+3
-2
tests/test_pagination.py
+7
-3
tests/test_parsers.py
+3
-1
tests/test_permissions.py
+11
-5
tests/test_relations.py
+7
-2
tests/test_relations_generic.py
+5
-1
tests/test_relations_hyperlink.py
+4
-2
tests/test_relations_pk.py
+4
-2
tests/test_relations_slug.py
+4
-1
tests/test_renderers.py
+11
-10
tests/test_request.py
+11
-12
tests/test_response.py
+8
-12
tests/test_reverse.py
+2
-0
tests/test_routers.py
+8
-5
tests/test_serializer.py
+7
-3
tests/test_serializer_bulk_update.py
+2
-0
tests/test_serializer_lists.py
+2
-1
tests/test_settings.py
+2
-0
tests/test_status.py
+4
-1
tests/test_templatetags.py
+5
-2
tests/test_testing.py
+7
-2
tests/test_throttling.py
+7
-3
tests/test_urlpatterns.py
+4
-2
tests/test_utils.py
+5
-4
tests/test_validation.py
+5
-2
tests/test_validators.py
+3
-1
tests/test_versioning.py
+6
-5
tests/test_views.py
+3
-1
tests/test_viewsets.py
+1
-1
tests/test_write_only_fields.py
+1
-0
No files found.
rest_framework/authentication.py
View file @
7351a3f6
...
...
@@ -9,9 +9,9 @@ from django.contrib.auth import authenticate
from
django.middleware.csrf
import
CsrfViewMiddleware
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
.compat
import
get_user_model
from
rest_framework
import
HTTP_HEADER_ENCODING
,
exceptions
from
rest_framework.authtoken.models
import
Token
from
rest_framework
import
exceptions
,
HTTP_HEADER_ENCODING
from
rest_framework
.compat
import
get_user_model
def
get_authorization_header
(
request
):
...
...
rest_framework/authtoken/migrations/0001_initial.py
View file @
7351a3f6
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
models
,
migrations
from
django.conf
import
settings
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
...
...
rest_framework/authtoken/models.py
View file @
7351a3f6
import
os
import
binascii
import
os
from
django.db
import
models
from
django.conf
import
settings
from
django.db
import
models
from
django.utils.encoding
import
python_2_unicode_compatible
# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
# Note that we don't perform this code in the compat module due to
# bug report #1297
...
...
rest_framework/authtoken/views.py
View file @
7351a3f6
from
rest_framework
import
parsers
,
renderers
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework.authtoken.models
import
Token
from
rest_framework.authtoken.serializers
import
AuthTokenSerializer
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
class
ObtainAuthToken
(
APIView
):
...
...
rest_framework/compat.py
View file @
7351a3f6
...
...
@@ -9,11 +9,12 @@ from __future__ import unicode_literals
import
inspect
import
django
from
django.utils
import
six
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
connection
,
transaction
from
django.test.client
import
FakePayload
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils.six.moves.urllib.parse
import
urlparse
as
_urlparse
try
:
...
...
@@ -202,7 +203,6 @@ if 'patch' not in View.http_method_names:
View
.
http_method_names
=
View
.
http_method_names
+
[
'patch'
]
from
django.test.client
import
FakePayload
try
:
# In 1.5 the test client uses force_bytes
...
...
rest_framework/exceptions.py
View file @
7351a3f6
...
...
@@ -10,7 +10,8 @@ import math
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.utils.translation
import
ugettext_lazy
as
_
,
ungettext
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ungettext
from
rest_framework
import
status
...
...
rest_framework/fields.py
View file @
7351a3f6
from
__future__
import
unicode_literals
import
re
import
collections
import
copy
import
uuid
import
datetime
import
decimal
import
inspect
import
datetim
e
import
collections
import
r
e
import
uuid
from
django.conf
import
settings
from
django.core.exceptions
import
ValidationError
as
DjangoValidationError
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.validators
import
RegexValidator
,
ip_address_validators
from
django.forms
import
ImageField
as
DjangoImageField
from
django.utils
import
six
,
timezone
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
from
django.utils.encoding
import
is_protected_type
,
smart_text
from
django.utils.ipv6
import
clean_ipv6_address
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.forms
import
ImageField
as
DjangoImageField
from
django.utils.encoding
import
is_protected_type
,
smart_text
from
django.core.validators
import
RegexValidator
,
ip_address_validators
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
from
django.core.exceptions
import
(
ObjectDoesNotExist
,
ValidationError
as
DjangoValidationError
)
from
rest_framework
import
ISO_8601
from
rest_framework.settings
import
api_settings
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.utils
import
html
,
representation
,
humanize_datetime
from
rest_framework.compat
import
(
EmailValidator
,
M
inValueValidator
,
MaxValue
Validator
,
Min
LengthValidator
,
MaxLengthValidator
,
URLValidator
,
OrderedDict
,
unicode_repr
,
unicode_to_repr
,
parse_duration
,
duration_string
,
EmailValidator
,
M
axLengthValidator
,
MaxValueValidator
,
MinLength
Validator
,
Min
ValueValidator
,
OrderedDict
,
URLValidator
,
duration_string
,
parse_duration
,
unicode_repr
,
unicode_to_repr
)
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.settings
import
api_settings
from
rest_framework.utils
import
html
,
humanize_datetime
,
representation
class
empty
:
...
...
rest_framework/filters.py
View file @
7351a3f6
...
...
@@ -7,13 +7,12 @@ from __future__ import unicode_literals
import
operator
from
functools
import
reduce
from
django.utils
import
six
from
django.db
import
models
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
models
from
django.utils
import
six
from
rest_framework.compat
import
django_filters
,
get_model_name
,
guardian
from
rest_framework.settings
import
api_settings
from
rest_framework.compat
import
django_filters
,
guardian
,
get_model_name
FilterSet
=
django_filters
and
django_filters
.
FilterSet
or
None
...
...
rest_framework/generics.py
View file @
7351a3f6
...
...
@@ -3,11 +3,11 @@ Generic views that provide commonly needed behaviour.
"""
from
__future__
import
unicode_literals
from
django.http
import
Http404
from
django.db.models.query
import
QuerySet
from
django.http
import
Http404
from
django.shortcuts
import
get_object_or_404
as
_get_object_or_404
from
rest_framework
import
views
,
mixin
s
from
rest_framework
import
mixins
,
view
s
from
rest_framework.settings
import
api_settings
...
...
rest_framework/metadata.py
View file @
7351a3f6
...
...
@@ -8,9 +8,9 @@ to return this information in a more standardized way.
"""
from
__future__
import
unicode_literals
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
Http404
from
django.utils.encoding
import
force_text
from
django.core.exceptions
import
PermissionDenied
from
rest_framework
import
exceptions
,
serializers
from
rest_framework.compat
import
OrderedDict
...
...
rest_framework/negotiation.py
View file @
7351a3f6
...
...
@@ -9,7 +9,7 @@ from django.http import Http404
from
rest_framework
import
HTTP_HEADER_ENCODING
,
exceptions
from
rest_framework.settings
import
api_settings
from
rest_framework.utils.mediatypes
import
(
_MediaType
,
order_by_precedence
,
media_type_matches
_MediaType
,
media_type_matches
,
order_by_precedence
)
...
...
rest_framework/pagination.py
View file @
7351a3f6
...
...
@@ -6,22 +6,21 @@ be used for paginated responses.
from
__future__
import
unicode_literals
import
warnings
from
base64
import
b64
encode
,
b64de
code
from
base64
import
b64
decode
,
b64en
code
from
collections
import
namedtuple
from
django.utils
import
six
from
django.core.paginator
import
Paginator
as
DjangoPaginator
from
django.core.paginator
import
InvalidPage
from
django.template
import
Context
,
loader
from
django.utils
.translation
import
ugettext_lazy
as
_
from
django.utils
import
six
from
django.utils.six.moves.urllib
import
parse
as
urlparse
from
django.
core.paginator
import
InvalidPage
,
Paginator
as
DjangoPaginator
from
django.
utils.translation
import
ugettext_lazy
as
_
from
rest_framework.response
import
Response
from
rest_framework.compat
import
OrderedDict
from
rest_framework.exceptions
import
NotFound
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.utils.urls
import
(
replace_query_param
,
remove_query_param
)
from
rest_framework.utils.urls
import
remove_query_param
,
replace_query_param
def
_positive_int
(
integer_string
,
strict
=
False
,
cutoff
=
None
):
...
...
rest_framework/parsers.py
View file @
7351a3f6
...
...
@@ -8,16 +8,17 @@ from __future__ import unicode_literals
import
json
from
django.utils
import
six
from
django.conf
import
settings
from
django.http
import
QueryDict
from
django.utils.encoding
import
force_text
from
django.utils.six.moves.urllib
import
parse
as
urlparse
from
django.core.files.uploadhandler
import
StopFutureHandlers
from
django.http
.multipartparser
import
(
MultiPartParserError
,
parse_header
,
ChunkIter
,
from
django.http
import
QueryDict
from
django.http.multipartparser
import
\
MultiPartParser
as
DjangoMultiPartParser
from
django.http.multipartparser
import
(
ChunkIter
,
MultiPartParserError
,
parse_header
)
from
django.utils
import
six
from
django.utils.encoding
import
force_text
from
django.utils.six.moves.urllib
import
parse
as
urlparse
from
rest_framework
import
renderers
from
rest_framework.exceptions
import
ParseError
...
...
rest_framework/permissions.py
View file @
7351a3f6
...
...
@@ -7,7 +7,6 @@ from django.http import Http404
from
rest_framework.compat
import
get_model_name
SAFE_METHODS
=
(
'GET'
,
'HEAD'
,
'OPTIONS'
)
...
...
rest_framework/relations.py
View file @
7351a3f6
# coding: utf-8
from
__future__
import
unicode_literals
from
django.utils
import
six
from
django.core.exceptions
import
ImproperlyConfigured
,
ObjectDoesNotExist
from
django.core.urlresolvers
import
(
NoReverseMatch
,
Resolver404
,
get_script_prefix
,
resolve
)
from
django.db.models.query
import
QuerySet
from
django.utils
import
six
from
django.utils.encoding
import
smart_text
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.six.moves.urllib
import
parse
as
urlparse
from
django.core.exceptions
import
ObjectDoesNotExist
,
ImproperlyConfigured
from
django.core.urlresolvers
import
(
get_script_prefix
,
resolve
,
NoReverseMatch
,
Resolver404
)
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework.utils
import
html
from
rest_framework.reverse
import
reverse
from
rest_framework.compat
import
OrderedDict
from
rest_framework.fields
import
get_attribute
,
empty
,
Field
from
rest_framework.fields
import
Field
,
empty
,
get_attribute
from
rest_framework.reverse
import
reverse
from
rest_framework.utils
import
html
class
PKOnlyObject
(
object
):
...
...
rest_framework/renderers.py
View file @
7351a3f6
...
...
@@ -12,23 +12,23 @@ import json
import
django
from
django
import
forms
from
django.
utils
import
six
from
django.
core.exceptions
import
ImproperlyConfigured
from
django.core.paginator
import
Page
from
django.test.client
import
encode_multipart
from
django.http.multipartparser
import
parse_header
from
django.core.exceptions
import
ImproperlyConfigured
from
django.template
import
Context
,
RequestContext
,
loader
,
Template
from
django.template
import
Context
,
RequestContext
,
Template
,
loader
from
django.test.client
import
encode_multipart
from
django.utils
import
six
from
rest_framework.utils
import
encoders
from
rest_framework
import
VERSION
,
exceptions
,
serializers
,
status
from
rest_framework.compat
import
(
INDENT_SEPARATORS
,
LONG_SEPARATORS
,
SHORT_SEPARATORS
)
from
rest_framework.exceptions
import
ParseError
from
rest_framework.request
import
is_form_media_type
,
override_method
from
rest_framework.settings
import
api_settings
from
rest_framework.utils
import
encoders
from
rest_framework.utils.breadcrumbs
import
get_breadcrumbs
from
rest_framework.utils.field_mapping
import
ClassLookupDict
from
rest_framework
import
exceptions
,
serializers
,
status
,
VERSION
from
rest_framework.request
import
is_form_media_type
,
override_method
from
rest_framework.compat
import
(
SHORT_SEPARATORS
,
LONG_SEPARATORS
,
INDENT_SEPARATORS
)
def
zero_as_none
(
value
):
...
...
rest_framework/request.py
View file @
7351a3f6
...
...
@@ -13,13 +13,13 @@ from __future__ import unicode_literals
import
sys
import
warnings
from
django.utils
import
six
from
django.conf
import
settings
from
django.http
import
QueryDict
from
django.http.multipartparser
import
parse_header
from
django.utils
import
six
from
django.utils.datastructures
import
MultiValueDict
from
rest_framework
import
exceptions
,
HTTP_HEADER_ENCODING
from
rest_framework
import
HTTP_HEADER_ENCODING
,
exceptions
from
rest_framework.settings
import
api_settings
...
...
rest_framework/response.py
View file @
7351a3f6
...
...
@@ -6,9 +6,9 @@ The appropriate renderer is called during Django's template response rendering.
"""
from
__future__
import
unicode_literals
from
django.template.response
import
SimpleTemplateResponse
from
django.utils
import
six
from
django.utils.six.moves.http_client
import
responses
from
django.template.response
import
SimpleTemplateResponse
class
Response
(
SimpleTemplateResponse
):
...
...
rest_framework/reverse.py
View file @
7351a3f6
...
...
@@ -3,9 +3,10 @@ Provide urlresolver functions that return fully qualified URLs or view names
"""
from
__future__
import
unicode_literals
from
django.core.urlresolvers
import
reverse
as
django_reverse
from
django.core.urlresolvers
import
NoReverseMatch
from
django.utils
import
six
from
django.utils.functional
import
lazy
from
django.core.urlresolvers
import
NoReverseMatch
,
reverse
as
django_reverse
def
reverse
(
viewname
,
args
=
None
,
kwargs
=
None
,
request
=
None
,
format
=
None
,
**
extra
):
...
...
rest_framework/routers.py
View file @
7351a3f6
...
...
@@ -19,16 +19,15 @@ import itertools
from
collections
import
namedtuple
from
django.conf.urls
import
url
from
django.core.urlresolvers
import
NoReverseMatch
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.urlresolvers
import
NoReverseMatch
from
rest_framework
import
views
from
rest_framework.
reverse
import
reverse
from
rest_framework.
compat
import
OrderedDict
,
get_resolver_match
from
rest_framework.response
import
Response
from
rest_framework.
compat
import
get_resolver_match
,
OrderedDict
from
rest_framework.
reverse
import
reverse
from
rest_framework.urlpatterns
import
format_suffix_patterns
Route
=
namedtuple
(
'Route'
,
[
'url'
,
'mapping'
,
'name'
,
'initkwargs'
])
DynamicDetailRoute
=
namedtuple
(
'DynamicDetailRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
DynamicListRoute
=
namedtuple
(
'DynamicListRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
...
...
rest_framework/serializers.py
View file @
7351a3f6
...
...
@@ -15,29 +15,26 @@ from __future__ import unicode_literals
import
warnings
from
django.db
import
models
from
django.db.models.fields
import
Field
as
DjangoModelField
from
django.db.models.fields
import
FieldDoesNotExist
from
django.utils.functional
import
cached_property
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.db.models.fields
import
(
FieldDoesNotExist
,
Field
as
DjangoModelField
)
from
rest_framework.compat
import
DurationField
as
ModelDurationField
from
rest_framework.compat
import
postgres_fields
,
unicode_to_repr
from
rest_framework.utils
import
model_meta
from
rest_framework.compat
import
(
postgres_fields
,
unicode_to_repr
,
DurationField
as
ModelDurationField
,
from
rest_framework.utils.field_mapping
import
(
ClassLookupDict
,
get_field_kwargs
,
get_nested_relation_kwargs
,
get_relation_kwargs
,
get_url_kwargs
)
from
rest_framework.utils.serializer_helpers
import
(
ReturnDict
,
ReturnList
,
BoundField
,
NestedBoundField
,
BindingDict
)
from
rest_framework.utils.field_mapping
import
(
get_url_kwargs
,
get_field_kwargs
,
get_relation_kwargs
,
get_nested_relation_kwargs
,
ClassLookupDict
BindingDict
,
BoundField
,
NestedBoundField
,
ReturnDict
,
ReturnList
)
from
rest_framework.validators
import
(
UniqueForDateValidator
,
UniqueForMonthValidator
,
UniqueForYearValidator
,
UniqueTogetherValidator
)
# Note: We do the following so that users of the framework can use this style:
#
# example_field = serializers.CharField(...)
...
...
@@ -45,9 +42,8 @@ from rest_framework.validators import (
# This helps keep the separation between model fields, form fields, and
# serializer fields more explicit.
from
rest_framework.relations
import
*
# NOQA
from
rest_framework.fields
import
*
# NOQA
from
rest_framework.fields
import
*
# NOQA # isort:skip
from
rest_framework.relations
import
*
# NOQA # isort:skip
# We assume that 'validators' are intended for the child serializer,
# rather than the parent serializer.
...
...
rest_framework/settings.py
View file @
7351a3f6
...
...
@@ -19,14 +19,13 @@ back to the defaults.
"""
from
__future__
import
unicode_literals
from
django.utils
import
six
from
django.conf
import
settings
from
django.test.signals
import
setting_changed
from
django.utils
import
six
from
rest_framework
import
ISO_8601
from
rest_framework.compat
import
importlib
USER_SETTINGS
=
getattr
(
settings
,
'REST_FRAMEWORK'
,
None
)
DEFAULTS
=
{
...
...
rest_framework/templatetags/rest_framework.py
View file @
7351a3f6
from
__future__
import
unicode_literals
,
absolute_import
from
__future__
import
absolute_import
,
unicode_literals
import
re
from
django
import
template
from
django.core.urlresolvers
import
NoReverseMatch
,
reverse
from
django.utils
import
six
from
django.utils.
html
import
escape
from
django.utils.html
import
smart_urlquote
from
django.utils.
encoding
import
force_text
,
iri_to_uri
from
django.utils.html
import
escape
,
smart_urlquote
from
django.utils.safestring
import
SafeData
,
mark_safe
from
django.utils.encoding
import
iri_to_uri
,
force_text
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
rest_framework.renderers
import
HTMLFormRenderer
from
rest_framework.utils.urls
import
replace_query_param
register
=
template
.
Library
()
# Regex for adding classes to html snippets
...
...
rest_framework/test.py
View file @
7351a3f6
...
...
@@ -5,16 +5,16 @@
from
__future__
import
unicode_literals
import
django
from
django.utils
import
six
from
django.conf
import
settings
from
django.test
import
testcases
from
django.test.client
import
Client
as
DjangoClient
from
django.test.client
import
ClientHandler
from
django.utils
import
six
from
django.utils.http
import
urlencode
from
django.test.client
import
ClientHandler
,
Client
as
DjangoClient
from
rest_framework.compat
import
RequestFactory
as
DjangoRequestFactory
from
rest_framework.compat
import
force_bytes_or_smart_bytes
from
rest_framework.settings
import
api_settings
from
rest_framework.compat
import
(
force_bytes_or_smart_bytes
,
RequestFactory
as
DjangoRequestFactory
)
def
force_authenticate
(
request
,
user
=
None
,
token
=
None
):
...
...
rest_framework/urlpatterns.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
include
,
url
from
django.core.urlresolvers
import
RegexURLResolver
from
rest_framework.settings
import
api_settings
...
...
rest_framework/urls.py
View file @
7351a3f6
...
...
@@ -17,7 +17,6 @@ from __future__ import unicode_literals
from
django.conf.urls
import
url
from
django.contrib.auth
import
views
template_name
=
{
'template_name'
:
'rest_framework/login.html'
}
urlpatterns
=
[
...
...
rest_framework/utils/breadcrumbs.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.core.urlresolvers
import
resolve
,
get_script_prefix
from
django.core.urlresolvers
import
get_script_prefix
,
resolve
def
get_breadcrumbs
(
url
):
...
...
rest_framework/utils/encoders.py
View file @
7351a3f6
...
...
@@ -3,15 +3,15 @@ Helper classes for parsers.
"""
from
__future__
import
unicode_literals
import
uuid
import
json
import
decimal
import
datetime
import
decimal
import
json
import
uuid
from
django.utils
import
six
,
timezone
from
django.db.models.query
import
QuerySet
from
django.utils
.functional
import
Promis
e
from
django.utils
import
six
,
timezon
e
from
django.utils.encoding
import
force_text
from
django.utils.functional
import
Promise
from
rest_framework.compat
import
total_seconds
...
...
rest_framework/utils/field_mapping.py
View file @
7351a3f6
...
...
@@ -4,14 +4,13 @@ keyword arguments that should be used for their equivelent serializer fields.
"""
import
inspect
from
django.db
import
models
from
django.core
import
validators
from
django.db
import
models
from
django.utils.text
import
capfirst
from
rest_framework.compat
import
clean_manytomany_helptext
from
rest_framework.validators
import
UniqueValidator
NUMERIC_FIELD_TYPES
=
(
models
.
IntegerField
,
models
.
FloatField
,
models
.
DecimalField
)
...
...
rest_framework/utils/model_meta.py
View file @
7351a3f6
...
...
@@ -8,13 +8,12 @@ Usage: `get_field_info(model)` returns a `FieldInfo` instance.
import
inspect
from
collections
import
namedtuple
from
django.utils
import
six
from
django.db
import
models
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
models
from
django.utils
import
six
from
rest_framework.compat
import
OrderedDict
FieldInfo
=
namedtuple
(
'FieldResult'
,
[
'pk'
,
# Model field instance
'fields'
,
# Dict of field name -> model field instance
...
...
rest_framework/utils/representation.py
View file @
7351a3f6
...
...
@@ -7,8 +7,8 @@ from __future__ import unicode_literals
import
re
from
django.db
import
models
from
django.utils.functional
import
Promise
from
django.utils.encoding
import
force_text
from
django.utils.functional
import
Promise
from
rest_framework.compat
import
unicode_repr
...
...
rest_framework/versioning.py
View file @
7351a3f6
...
...
@@ -6,11 +6,11 @@ import re
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
import
exceptions
from
rest_framework.compat
import
unicode_http_header
from
rest_framework.reverse
import
_reverse
from
rest_framework.settings
import
api_settings
from
rest_framework.compat
import
unicode_http_header
from
rest_framework.utils.mediatypes
import
_MediaType
from
rest_framework.templatetags.rest_framework
import
replace_query_param
from
rest_framework.utils.mediatypes
import
_MediaType
class
BaseVersioning
(
object
):
...
...
rest_framework/views.py
View file @
7351a3f6
...
...
@@ -6,19 +6,19 @@ from __future__ import unicode_literals
import
inspect
import
warnings
from
django.
utils
import
six
from
django.
core.exceptions
import
PermissionDenied
from
django.http
import
Http404
from
django.utils
import
six
from
django.utils.encoding
import
smart_text
from
django.core.exceptions
import
PermissionDenied
from
django.views.decorators.csrf
import
csrf_exempt
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework
import
status
,
exceptions
from
rest_framework
import
exceptions
,
status
from
rest_framework.compat
import
HttpResponseBase
,
View
,
set_rollback
from
rest_framework.request
import
Request
from
rest_framework.utils
import
formatting
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.
compat
import
HttpResponseBase
,
View
,
set_rollback
from
rest_framework.
utils
import
formatting
def
get_view_name
(
view_cls
,
suffix
=
None
):
...
...
rest_framework/viewsets.py
View file @
7351a3f6
...
...
@@ -23,7 +23,7 @@ from functools import update_wrapper
from
django.utils.decorators
import
classonlymethod
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework
import
views
,
generics
,
mixin
s
from
rest_framework
import
generics
,
mixins
,
view
s
class
ViewSetMixin
(
object
):
...
...
setup.py
View file @
7351a3f6
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
re
import
os
import
re
import
sys
from
setuptools
import
setup
...
...
tests/browsable_api/auth_urls.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
,
include
from
.views
import
MockView
from
django.conf.urls
import
include
,
url
from
.views
import
MockView
urlpatterns
=
[
url
(
r'^$'
,
MockView
.
as_view
()),
...
...
tests/browsable_api/no_auth_urls.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
from
.views
import
MockView
urlpatterns
=
[
...
...
tests/browsable_api/test_browsable_api.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
...
...
tests/browsable_api/views.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
rest_framework.views
import
APIView
from
rest_framework
import
authentication
from
rest_framework
import
renderers
from
rest_framework
import
authentication
,
renderers
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
class
MockView
(
APIView
):
...
...
tests/description.py
View file @
7351a3f6
...
...
@@ -8,7 +8,6 @@
from
rest_framework.views
import
APIView
# test strings snatched from http://www.columbia.edu/~fdc/utf8/,
# http://winrus.com/utf8-jap.htm and memory
UTF8_TEST_DOCSTRING
=
(
...
...
tests/test_atomic_requests.py
View file @
7351a3f6
...
...
@@ -2,10 +2,11 @@ from __future__ import unicode_literals
from
django.conf.urls
import
patterns
,
url
from
django.db
import
connection
,
connections
,
transaction
from
django.test
import
TestCase
,
TransactionTestCase
from
django.http
import
Http404
from
django.test
import
TestCase
,
TransactionTestCase
from
django.utils.decorators
import
method_decorator
from
django.utils.unittest
import
skipUnless
from
rest_framework
import
status
from
rest_framework.exceptions
import
APIException
from
rest_framework.response
import
Response
...
...
@@ -13,7 +14,6 @@ from rest_framework.test import APIRequestFactory
from
rest_framework.views
import
APIView
from
tests.models
import
BasicModel
factory
=
APIRequestFactory
()
...
...
tests/test_authentication.py
View file @
7351a3f6
# coding: utf-8
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
,
include
import
base64
from
django.conf.urls
import
include
,
url
from
django.contrib.auth.models
import
User
from
django.http
import
HttpResponse
from
django.test
import
TestCase
from
django.utils
import
six
from
rest_framework
import
HTTP_HEADER_ENCODING
from
rest_framework
import
exceptions
from
rest_framework
import
permissions
from
rest_framework
import
renderers
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
rest_framework
import
(
HTTP_HEADER_ENCODING
,
exceptions
,
permissions
,
renderers
,
status
)
from
rest_framework.authentication
import
(
BaseAuthentication
,
TokenAuthentication
,
BasicAuthentication
,
SessionAuthentication
,
BaseAuthentication
,
BasicAuthentication
,
SessionAuthentication
,
TokenAuthentication
)
from
rest_framework.authtoken.models
import
Token
from
rest_framework.test
import
APIRequestFactory
,
APIClient
from
rest_framework.response
import
Response
from
rest_framework.test
import
APIClient
,
APIRequestFactory
from
rest_framework.views
import
APIView
import
base64
factory
=
APIRequestFactory
()
...
...
tests/test_decorators.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework
import
status
from
rest_framework.authentication
import
BasicAuthentication
from
rest_framework.decorators
import
(
api_view
,
authentication_classes
,
parser_classes
,
permission_classes
,
renderer_classes
,
throttle_classes
)
from
rest_framework.parsers
import
JSONParser
from
rest_framework.permissions
import
IsAuthenticated
from
rest_framework.response
import
Response
from
rest_framework.renderers
import
JSONRenderer
from
rest_framework.response
import
Response
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.throttling
import
UserRateThrottle
from
rest_framework.views
import
APIView
from
rest_framework.decorators
import
(
api_view
,
renderer_classes
,
parser_classes
,
authentication_classes
,
throttle_classes
,
permission_classes
,
)
class
DecoratorTestCase
(
TestCase
):
...
...
tests/test_description.py
View file @
7351a3f6
# -- coding: utf-8 --
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.utils.encoding
import
python_2_unicode_compatible
,
smart_text
from
rest_framework.compat
import
apply_markdown
from
rest_framework.views
import
APIView
from
.description
import
ViewWithNonASCIICharactersInDocstring
from
.description
import
UTF8_TEST_DOCSTRING
from
.description
import
(
UTF8_TEST_DOCSTRING
,
ViewWithNonASCIICharactersInDocstring
)
# We check that docstrings get nicely un-indented.
DESCRIPTION
=
"""an example docstring
...
...
tests/test_fields.py
View file @
7351a3f6
from
decimal
import
Decimal
from
django.utils
import
timezone
from
rest_framework
import
serializers
import
rest_framework
import
datetime
import
uuid
from
decimal
import
Decimal
import
django
import
pytest
import
uuid
from
django.utils
import
timezone
import
rest_framework
from
rest_framework
import
serializers
# Tests for field keyword arguments and core functionality.
...
...
tests/test_filters.py
View file @
7351a3f6
from
__future__
import
unicode_literals
import
datetime
from
decimal
import
Decimal
from
django.db
import
models
from
django.conf.urls
import
url
from
django.core.urlresolvers
import
reverse
from
django.db
import
models
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.utils
import
unittest
from
django.utils.dateparse
import
parse_date
from
django.utils.six.moves
import
reload_module
from
rest_framework
import
generics
,
serializers
,
status
,
filters
from
rest_framework
import
filters
,
generics
,
serializers
,
status
from
rest_framework.compat
import
django_filters
from
rest_framework.test
import
APIRequestFactory
from
.models
import
BaseFilterableItem
,
FilterableItem
,
BasicModel
from
.models
import
BaseFilterableItem
,
BasicModel
,
FilterableItem
factory
=
APIRequestFactory
()
...
...
tests/test_generics.py
View file @
7351a3f6
from
__future__
import
unicode_literals
import
django
from
django.db
import
models
from
django.shortcuts
import
get_object_or_404
from
django.test
import
TestCase
from
django.utils
import
six
from
rest_framework
import
generics
,
renderers
,
serializers
,
status
from
rest_framework.test
import
APIRequestFactory
from
tests.models
import
BasicModel
,
RESTFrameworkModel
from
tests.models
import
ForeignKeySource
,
ForeignKeyTarget
from
tests.models
import
(
BasicModel
,
ForeignKeySource
,
ForeignKeyTarget
,
RESTFrameworkModel
)
factory
=
APIRequestFactory
()
...
...
tests/test_htmlrenderer.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.core.exceptions
import
PermissionDenied
import
django.template.loader
from
django.conf.urls
import
url
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
Http404
from
django.template
import
Template
,
TemplateDoesNotExist
from
django.test
import
TestCase
from
django.template
import
TemplateDoesNotExist
,
Template
from
django.utils
import
six
from
rest_framework
import
status
from
rest_framework.decorators
import
api_view
,
renderer_classes
from
rest_framework.renderers
import
TemplateHTMLRenderer
from
rest_framework.response
import
Response
import
django.template.loader
@api_view
((
'GET'
,))
...
...
tests/test_metadata.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.core.validators
import
MaxValueValidator
,
MinValueValidator
from
django.db
import
models
from
django.test
import
TestCase
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
rest_framework
import
exceptions
,
metadata
,
serializers
,
status
,
views
,
versioning
from
rest_framework.request
import
Request
from
rest_framework
import
(
exceptions
,
metadata
,
serializers
,
status
,
versioning
,
views
)
from
rest_framework.renderers
import
BrowsableAPIRenderer
from
rest_framework.request
import
Request
from
rest_framework.test
import
APIRequestFactory
request
=
Request
(
APIRequestFactory
()
.
options
(
'/'
))
...
...
tests/test_middleware.py
View file @
7351a3f6
from
django.conf.urls
import
url
from
django.contrib.auth.models
import
User
from
rest_framework.authentication
import
TokenAuthentication
from
rest_framework.authtoken.models
import
Token
from
rest_framework.test
import
APITestCase
from
rest_framework.views
import
APIView
urlpatterns
=
[
url
(
r'^$'
,
APIView
.
as_view
(
authentication_classes
=
(
TokenAuthentication
,))),
]
...
...
tests/test_model_serializer.py
View file @
7351a3f6
...
...
@@ -6,15 +6,20 @@ These tests deal with ensuring that we correctly map the model fields onto
an appropriate set of serializer fields for each case.
"""
from
__future__
import
unicode_literals
import
django
import
pytest
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.validators
import
MaxValueValidator
,
MinValueValidator
,
MinLengthValidator
from
django.core.validators
import
(
MaxValueValidator
,
MinLengthValidator
,
MinValueValidator
)
from
django.db
import
models
from
django.test
import
TestCase
from
django.utils
import
six
import
pytest
from
rest_framework
import
serializers
from
rest_framework.compat
import
unicode_repr
,
DurationField
as
ModelDurationField
from
rest_framework.compat
import
DurationField
as
ModelDurationField
from
rest_framework.compat
import
unicode_repr
def
dedent
(
blocktext
):
...
...
tests/test_multitable_inheritance.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.db
import
models
from
django.test
import
TestCase
from
rest_framework
import
serializers
from
tests.models
import
RESTFrameworkModel
...
...
tests/test_negotiation.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework.negotiation
import
DefaultContentNegotiation
from
rest_framework.request
import
Request
from
rest_framework.renderers
import
BaseRenderer
from
rest_framework.request
import
Request
from
rest_framework.test
import
APIRequestFactory
factory
=
APIRequestFactory
()
...
...
tests/test_pagination.py
View file @
7351a3f6
# coding: utf-8
from
__future__
import
unicode_literals
from
rest_framework
import
exceptions
,
generics
,
pagination
,
serializers
,
status
,
filters
import
pytest
from
rest_framework
import
(
exceptions
,
filters
,
generics
,
pagination
,
serializers
,
status
)
from
rest_framework.pagination
import
PAGE_BREAK
,
PageLink
from
rest_framework.request
import
Request
from
rest_framework.pagination
import
PageLink
,
PAGE_BREAK
from
rest_framework.test
import
APIRequestFactory
import
pytest
factory
=
APIRequestFactory
()
...
...
tests/test_parsers.py
View file @
7351a3f6
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django
import
forms
from
django.core.files.uploadhandler
import
MemoryFileUploadHandler
from
django.test
import
TestCase
from
django.utils.six.moves
import
StringIO
from
rest_framework.exceptions
import
ParseError
from
rest_framework.parsers
import
F
ormParser
,
FileUpload
Parser
from
rest_framework.parsers
import
F
ileUploadParser
,
Form
Parser
class
Form
(
forms
.
Form
):
...
...
tests/test_permissions.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.contrib.auth.models
import
User
,
Permission
,
Group
import
base64
from
django.contrib.auth.models
import
Group
,
Permission
,
User
from
django.core.urlresolvers
import
ResolverMatch
from
django.db
import
models
from
django.test
import
TestCase
from
django.utils
import
unittest
from
rest_framework
import
generics
,
serializers
,
status
,
permissions
,
authentication
,
HTTP_HEADER_ENCODING
from
rest_framework.compat
import
guardian
,
get_model_name
from
django.core.urlresolvers
import
ResolverMatch
from
rest_framework
import
(
HTTP_HEADER_ENCODING
,
authentication
,
generics
,
permissions
,
serializers
,
status
)
from
rest_framework.compat
import
get_model_name
,
guardian
from
rest_framework.filters
import
DjangoObjectPermissionsFilter
from
rest_framework.routers
import
DefaultRouter
from
rest_framework.test
import
APIRequestFactory
from
tests.models
import
BasicModel
import
base64
factory
=
APIRequestFactory
()
...
...
tests/test_relations.py
View file @
7351a3f6
import
uuid
from
.utils
import
mock_reverse
,
fail_reverse
,
BadType
,
MockObject
,
MockQueryset
import
pytest
from
django.core.exceptions
import
ImproperlyConfigured
from
django.utils.datastructures
import
MultiValueDict
from
rest_framework
import
serializers
from
rest_framework.fields
import
empty
from
rest_framework.test
import
APISimpleTestCase
import
pytest
from
.utils
import
(
BadType
,
MockObject
,
MockQueryset
,
fail_reverse
,
mock_reverse
)
class
TestStringRelatedField
(
APISimpleTestCase
):
...
...
tests/test_relations_generic.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.contrib.contenttypes.generic
import
(
GenericForeignKey
,
GenericRelation
)
from
django.contrib.contenttypes.models
import
ContentType
from
django.contrib.contenttypes.generic
import
GenericRelation
,
GenericForeignKey
from
django.db
import
models
from
django.test
import
TestCase
from
django.utils.encoding
import
python_2_unicode_compatible
from
rest_framework
import
serializers
...
...
tests/test_relations_hyperlink.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
from
django.test
import
TestCase
from
rest_framework
import
serializers
from
rest_framework.test
import
APIRequestFactory
from
tests.models
import
(
ManyToManyTarget
,
ManyToManySource
,
ForeignKeyTarget
,
ForeignKeySource
,
NullableForeignKeySource
,
OneToOneTarget
,
NullableOneToOneSource
ForeignKeySource
,
ForeignKeyTarget
,
ManyToManySource
,
ManyToManyTarget
,
NullableForeignKeySource
,
NullableOneToOneSource
,
OneToOneTarget
)
factory
=
APIRequestFactory
()
...
...
tests/test_relations_pk.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.utils
import
six
from
rest_framework
import
serializers
from
tests.models
import
(
ManyToManyTarget
,
ManyToManySource
,
ForeignKeyTarget
,
ForeignKeySource
,
NullableForeignKeySource
,
OneToOneTarget
,
NullableOneToOneSource
,
ForeignKeySource
,
ForeignKeyTarget
,
ManyToManySource
,
ManyToManyTarget
,
NullableForeignKeySource
,
NullableOneToOneSource
,
OneToOneTarget
)
...
...
tests/test_relations_slug.py
View file @
7351a3f6
from
django.test
import
TestCase
from
rest_framework
import
serializers
from
tests.models
import
NullableForeignKeySource
,
ForeignKeySource
,
ForeignKeyTarget
from
tests.models
import
(
ForeignKeySource
,
ForeignKeyTarget
,
NullableForeignKeySource
)
class
ForeignKeyTargetSerializer
(
serializers
.
ModelSerializer
):
...
...
tests/test_renderers.py
View file @
7351a3f6
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
,
include
import
json
import
re
from
collections
import
MutableMapping
from
django.conf.urls
import
include
,
url
from
django.core.cache
import
cache
from
django.db
import
models
from
django.test
import
TestCase
from
django.utils
import
six
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
import
status
,
permissions
from
rest_framework
import
permissions
,
serializers
,
status
from
rest_framework.compat
import
OrderedDict
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework
import
serializers
from
rest_framework.renderers
import
(
BaseRenderer
,
JSONRenderer
,
BrowsableAPIRenderer
,
HTMLForm
Renderer
BaseRenderer
,
BrowsableAPIRenderer
,
HTMLFormRenderer
,
JSON
Renderer
)
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.test
import
APIRequestFactory
from
collections
import
MutableMapping
import
json
import
re
from
rest_framework.views
import
APIView
DUMMYSTATUS
=
status
.
HTTP_200_OK
DUMMYCONTENT
=
'dummycontent'
...
...
tests/test_request.py
View file @
7351a3f6
...
...
@@ -2,31 +2,30 @@
Tests for content parsing, and form-overloaded content parsing.
"""
from
__future__
import
unicode_literals
import
json
from
io
import
BytesIO
import
django
import
pytest
from
django.conf.urls
import
url
from
django.contrib.auth.models
import
User
from
django.contrib.auth
import
authenticate
,
login
,
logout
from
django.contrib.auth.models
import
User
from
django.contrib.sessions.middleware
import
SessionMiddleware
from
django.core.handlers.wsgi
import
WSGIRequest
from
django.test
import
TestCase
from
django.utils
import
six
from
rest_framework
import
status
from
rest_framework.authentication
import
SessionAuthentication
from
rest_framework.parsers
import
(
BaseParser
,
FormParser
,
MultiPartParser
,
JSONParser
BaseParser
,
FormParser
,
JSONParser
,
MultiPartParser
)
from
rest_framework.request
import
Request
,
Empty
from
rest_framework.request
import
Empty
,
Request
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.test
import
API
RequestFactory
,
APIClient
from
rest_framework.test
import
API
Client
,
APIRequestFactory
from
rest_framework.views
import
APIView
from
io
import
BytesIO
import
json
import
django
import
pytest
factory
=
APIRequestFactory
()
...
...
tests/test_response.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
include
,
url
from
django.test
import
TestCase
from
django.utils
import
six
from
tests.models
import
BasicModel
from
rest_framework.response
import
Response
from
rest_framework.views
import
APIView
from
rest_framework
import
generics
from
rest_framework
import
routers
from
rest_framework
import
serializers
from
rest_framework
import
status
from
rest_framework
import
generics
,
routers
,
serializers
,
status
,
viewsets
from
rest_framework.renderers
import
(
BaseRenderer
,
JSONRenderer
,
BrowsableAPIRenderer
BaseRenderer
,
BrowsableAPIRenderer
,
JSONRenderer
)
from
rest_framework
import
viewsets
from
rest_framework
.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.views
import
APIView
from
tests.models
import
BasicModel
# Serializer used to test BasicModel
...
...
tests/test_reverse.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
from
django.core.urlresolvers
import
NoReverseMatch
from
django.test
import
TestCase
from
rest_framework.reverse
import
reverse
from
rest_framework.test
import
APIRequestFactory
...
...
tests/test_routers.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.conf.urls
import
url
,
include
from
collections
import
namedtuple
from
django.conf.urls
import
include
,
url
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
models
from
django.test
import
TestCase
from
django.core.exceptions
import
ImproperlyConfigured
from
rest_framework
import
serializers
,
viewsets
,
permission
s
from
rest_framework
import
permissions
,
serializers
,
viewset
s
from
rest_framework.decorators
import
detail_route
,
list_route
from
rest_framework.response
import
Response
from
rest_framework.routers
import
SimpleRouter
,
Default
Router
from
rest_framework.routers
import
DefaultRouter
,
Simple
Router
from
rest_framework.test
import
APIRequestFactory
from
collections
import
namedtuple
factory
=
APIRequestFactory
()
...
...
tests/test_serializer.py
View file @
7351a3f6
# coding: utf-8
from
__future__
import
unicode_literals
from
.utils
import
MockObject
from
rest_framework
import
serializers
from
rest_framework.compat
import
unicode_repr
import
pickle
import
pytest
from
rest_framework
import
serializers
from
rest_framework.compat
import
unicode_repr
from
.utils
import
MockObject
# Tests for core functionality.
# -----------------------------
...
...
tests/test_serializer_bulk_update.py
View file @
7351a3f6
...
...
@@ -2,8 +2,10 @@
Tests to cover bulk create and update using serializers.
"""
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.utils
import
six
from
rest_framework
import
serializers
...
...
tests/test_serializer_lists.py
View file @
7351a3f6
from
rest_framework
import
serializers
from
django.utils.datastructures
import
MultiValueDict
from
rest_framework
import
serializers
class
BasicObject
:
"""
...
...
tests/test_settings.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework.settings
import
APISettings
...
...
tests/test_status.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework.status
import
(
is_informational
,
is_success
,
is_redirect
,
is_client_error
,
is_server_error
is_client_error
,
is_informational
,
is_redirect
,
is_server_error
,
is_success
)
...
...
tests/test_templatetags.py
View file @
7351a3f6
# encoding: utf-8
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.templatetags.rest_framework
import
add_query_param
,
urlize_quoted_links
from
rest_framework.templatetags.rest_framework
import
(
add_query_param
,
urlize_quoted_links
)
from
rest_framework.test
import
APIRequestFactory
factory
=
APIRequestFactory
()
...
...
tests/test_testing.py
View file @
7351a3f6
# encoding: utf-8
from
__future__
import
unicode_literals
from
io
import
BytesIO
from
django.conf.urls
import
url
from
django.contrib.auth.models
import
User
from
django.shortcuts
import
redirect
from
django.test
import
TestCase
from
rest_framework.decorators
import
api_view
from
rest_framework.response
import
Response
from
rest_framework.test
import
APIClient
,
APIRequestFactory
,
force_authenticate
from
io
import
BytesIO
from
rest_framework.test
import
(
APIClient
,
APIRequestFactory
,
force_authenticate
)
@api_view
([
'GET'
,
'POST'
])
...
...
tests/test_throttling.py
View file @
7351a3f6
...
...
@@ -2,14 +2,18 @@
Tests for the throttling implementations in the permissions module.
"""
from
__future__
import
unicode_literals
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
django.core.cache
import
cache
from
django.test
import
TestCase
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.throttling
import
(
BaseThrottle
,
ScopedRateThrottle
,
UserRateThrottle
)
from
rest_framework.views
import
APIView
from
rest_framework.throttling
import
BaseThrottle
,
UserRateThrottle
,
ScopedRateThrottle
from
rest_framework.response
import
Response
class
User3SecRateThrottle
(
UserRateThrottle
):
...
...
tests/test_urlpatterns.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
collections
import
namedtuple
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
include
,
url
from
django.core
import
urlresolvers
from
django.test
import
TestCase
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.urlpatterns
import
format_suffix_patterns
# A container class for test paths for the test case
URLTestPath
=
namedtuple
(
'URLTestPath'
,
[
'path'
,
'args'
,
'kwargs'
])
...
...
tests/test_utils.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.core.exceptions
import
ImproperlyConfigured
from
django.conf.urls
import
url
from
django.core.exceptions
import
ImproperlyConfigured
from
django.test
import
TestCase
from
django.utils
import
six
from
rest_framework.utils.model_meta
import
_resolve_model
import
rest_framework.utils.model_meta
from
rest_framework.utils.breadcrumbs
import
get_breadcrumbs
from
rest_framework.utils.model_meta
import
_resolve_model
from
rest_framework.views
import
APIView
from
tests.models
import
BasicModel
import
rest_framework.utils.model_meta
class
Root
(
APIView
):
pass
...
...
tests/test_validation.py
View file @
7351a3f6
from
__future__
import
unicode_literals
from
django.core.validators
import
RegexValidator
,
MaxValueValidator
import
re
from
django.core.validators
import
MaxValueValidator
,
RegexValidator
from
django.db
import
models
from
django.test
import
TestCase
from
rest_framework
import
generics
,
serializers
,
status
from
rest_framework.test
import
APIRequestFactory
import
re
factory
=
APIRequestFactory
()
...
...
tests/test_validators.py
View file @
7351a3f6
import
datetime
from
django.db
import
models
from
django.test
import
TestCase
from
rest_framework
import
serializers
import
datetime
def
dedent
(
blocktext
):
...
...
tests/test_versioning.py
View file @
7351a3f6
from
.utils
import
UsingURLPatterns
import
pytest
from
django.conf.urls
import
include
,
url
from
rest_framework
import
serializers
from
rest_framework
import
status
,
versioning
from
rest_framework
import
s
erializers
,
s
tatus
,
versioning
from
rest_framework.decorators
import
APIView
from
rest_framework.relations
import
PKOnlyObject
from
rest_framework.response
import
Response
from
rest_framework.reverse
import
reverse
from
rest_framework.test
import
APIRequestFactory
,
APITestCase
from
rest_framework.versioning
import
NamespaceVersioning
from
rest_framework.relations
import
PKOnlyObject
import
pytest
from
.utils
import
UsingURLPatterns
class
RequestVersionView
(
APIView
):
...
...
tests/test_views.py
View file @
7351a3f6
from
__future__
import
unicode_literals
import
sys
import
copy
import
sys
from
django.test
import
TestCase
from
rest_framework
import
status
from
rest_framework.decorators
import
api_view
from
rest_framework.response
import
Response
...
...
tests/test_viewsets.py
View file @
7351a3f6
from
django.test
import
TestCase
from
rest_framework
import
status
from
rest_framework.response
import
Response
from
rest_framework.test
import
APIRequestFactory
from
rest_framework.viewsets
import
GenericViewSet
factory
=
APIRequestFactory
()
...
...
tests/test_write_only_fields.py
View file @
7351a3f6
from
django.test
import
TestCase
from
rest_framework
import
serializers
...
...
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