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
f0b3b9d7
Commit
f0b3b9d7
authored
Jun 11, 2011
by
markotibold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fix
parent
7bed352e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
djangorestframework/tests/throttling.py
+5
-5
No files found.
djangorestframework/tests/throttling.py
View file @
f0b3b9d7
...
...
@@ -53,26 +53,26 @@ class ThrottlingTests(TestCase):
response
=
MockView
.
as_view
()(
request
)
self
.
assertEqual
(
200
,
response
.
status_code
)
def
ensure_is_throttled
(
self
,
view
):
def
ensure_is_throttled
(
self
,
view
,
expect
):
request
=
self
.
factory
.
get
(
'/'
)
request
.
user
=
User
.
objects
.
create
(
username
=
'a'
)
for
dummy
in
range
(
3
):
response
=
view
.
as_view
()(
request
)
request
.
user
=
User
.
objects
.
create
(
username
=
'b'
)
response
=
view
.
as_view
()(
request
)
self
.
assertEqual
(
503
,
response
.
status_code
)
self
.
assertEqual
(
expect
,
response
.
status_code
)
def
test_request_throttling_is_per_user
(
self
):
"""Ensure request rate is only limited per user, not globally for PerUserTrottles"""
self
.
ensure_is_throttled
(
MockView
)
self
.
ensure_is_throttled
(
MockView
,
200
)
def
test_request_throttling_is_per_view
(
self
):
"""Ensure request rate is limited globally per View for PerViewThrottles"""
self
.
ensure_is_throttled
(
MockView1
)
self
.
ensure_is_throttled
(
MockView1
,
503
)
def
test_request_throttling_is_per_resource
(
self
):
"""Ensure request rate is limited globally per Resource for PerResourceThrottles"""
self
.
ensure_is_throttled
(
MockView3
)
self
.
ensure_is_throttled
(
MockView3
,
503
)
def
test_raises_no_resource_found
(
self
):
"""Ensure an Exception is raised when someone sets at per-resource 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