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
b2939c15
Commit
b2939c15
authored
Feb 09, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for latest version of pep8
parent
0669f507
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
9 deletions
+32
-9
env/pip-selfcheck.json
+2
-0
rest_framework/templatetags/rest_framework.py
+3
-1
tests/test_authentication.py
+4
-1
tests/test_relations_hyperlink.py
+3
-1
tests/test_renderers.py
+7
-2
tests/test_response.py
+7
-2
tests/test_throttling.py
+6
-2
No files found.
env/pip-selfcheck.json
0 → 100644
View file @
b2939c15
{
"last_check"
:
"2015-02-09T17:34:33Z"
,
"pypi_version"
:
"6.0.8"
}
\ No newline at end of file
rest_framework/templatetags/rest_framework.py
View file @
b2939c15
...
...
@@ -154,7 +154,9 @@ def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=Tru
If autoescape is True, the link text and URLs will get autoescaped.
"""
trim_url
=
lambda
x
,
limit
=
trim_url_limit
:
limit
is
not
None
and
(
len
(
x
)
>
limit
and
(
'
%
s...'
%
x
[:
max
(
0
,
limit
-
3
)]))
or
x
def
trim_url
(
x
,
limit
=
trim_url_limit
):
return
limit
is
not
None
and
(
len
(
x
)
>
limit
and
(
'
%
s...'
%
x
[:
max
(
0
,
limit
-
3
)]))
or
x
safe_input
=
isinstance
(
text
,
SafeData
)
words
=
word_split_re
.
split
(
force_text
(
text
))
for
i
,
word
in
enumerate
(
words
):
...
...
tests/test_authentication.py
View file @
b2939c15
...
...
@@ -205,7 +205,10 @@ class TokenAuthTests(TestCase):
def
test_post_json_makes_one_db_query
(
self
):
"""Ensure that authenticating a user using a token performs only one DB query"""
auth
=
"Token "
+
self
.
key
func_to_test
=
lambda
:
self
.
csrf_client
.
post
(
'/token/'
,
{
'example'
:
'example'
},
format
=
'json'
,
HTTP_AUTHORIZATION
=
auth
)
def
func_to_test
():
return
self
.
csrf_client
.
post
(
'/token/'
,
{
'example'
:
'example'
},
format
=
'json'
,
HTTP_AUTHORIZATION
=
auth
)
self
.
assertNumQueries
(
1
,
func_to_test
)
def
test_post_form_failing_token_auth
(
self
):
...
...
tests/test_relations_hyperlink.py
View file @
b2939c15
...
...
@@ -12,7 +12,9 @@ factory = APIRequestFactory()
request
=
factory
.
get
(
'/'
)
# Just to ensure we have a request in the serializer context
dummy_view
=
lambda
request
,
pk
:
None
def
dummy_view
(
request
,
pk
):
pass
urlpatterns
=
patterns
(
''
,
...
...
tests/test_renderers.py
View file @
b2939c15
...
...
@@ -28,8 +28,13 @@ import re
DUMMYSTATUS
=
status
.
HTTP_200_OK
DUMMYCONTENT
=
'dummycontent'
RENDERER_A_SERIALIZER
=
lambda
x
:
(
'Renderer A:
%
s'
%
x
)
.
encode
(
'ascii'
)
RENDERER_B_SERIALIZER
=
lambda
x
:
(
'Renderer B:
%
s'
%
x
)
.
encode
(
'ascii'
)
def
RENDERER_A_SERIALIZER
(
x
):
return
(
'Renderer A:
%
s'
%
x
)
.
encode
(
'ascii'
)
def
RENDERER_B_SERIALIZER
(
x
):
return
(
'Renderer B:
%
s'
%
x
)
.
encode
(
'ascii'
)
expected_results
=
[
...
...
tests/test_response.py
View file @
b2939c15
...
...
@@ -38,8 +38,13 @@ class MockTextMediaRenderer(BaseRenderer):
DUMMYSTATUS
=
status
.
HTTP_200_OK
DUMMYCONTENT
=
'dummycontent'
RENDERER_A_SERIALIZER
=
lambda
x
:
(
'Renderer A:
%
s'
%
x
)
.
encode
(
'ascii'
)
RENDERER_B_SERIALIZER
=
lambda
x
:
(
'Renderer B:
%
s'
%
x
)
.
encode
(
'ascii'
)
def
RENDERER_A_SERIALIZER
(
x
):
return
(
'Renderer A:
%
s'
%
x
)
.
encode
(
'ascii'
)
def
RENDERER_B_SERIALIZER
(
x
):
return
(
'Renderer B:
%
s'
%
x
)
.
encode
(
'ascii'
)
class
RendererA
(
BaseRenderer
):
...
...
tests/test_throttling.py
View file @
b2939c15
...
...
@@ -188,7 +188,9 @@ class ScopedRateThrottleTests(TestCase):
class
XYScopedRateThrottle
(
ScopedRateThrottle
):
TIMER_SECONDS
=
0
THROTTLE_RATES
=
{
'x'
:
'3/min'
,
'y'
:
'1/min'
}
timer
=
lambda
self
:
self
.
TIMER_SECONDS
def
timer
(
self
):
return
self
.
TIMER_SECONDS
class
XView
(
APIView
):
throttle_classes
=
(
XYScopedRateThrottle
,)
...
...
@@ -290,7 +292,9 @@ class XffTestingBase(TestCase):
class
Throttle
(
ScopedRateThrottle
):
THROTTLE_RATES
=
{
'test_limit'
:
'1/day'
}
TIMER_SECONDS
=
0
timer
=
lambda
self
:
self
.
TIMER_SECONDS
def
timer
(
self
):
return
self
.
TIMER_SECONDS
class
View
(
APIView
):
throttle_classes
=
(
Throttle
,)
...
...
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