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
dd11bd42
Commit
dd11bd42
authored
Jan 11, 2017
by
Artem Muterko
Committed by
Tom Christie
Jan 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add remaining tests for SimpleRateThrottle (#4803)
parent
14baf7eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
tests/test_throttling.py
+17
-0
No files found.
tests/test_throttling.py
View file @
dd11bd42
...
@@ -397,3 +397,20 @@ class SimpleRateThrottleTests(TestCase):
...
@@ -397,3 +397,20 @@ class SimpleRateThrottleTests(TestCase):
throttle
.
rate
=
'some rate'
throttle
.
rate
=
'some rate'
throttle
.
get_cache_key
=
lambda
*
args
:
None
throttle
.
get_cache_key
=
lambda
*
args
:
None
assert
throttle
.
allow_request
(
request
=
{},
view
=
{})
is
True
assert
throttle
.
allow_request
(
request
=
{},
view
=
{})
is
True
def
test_wait_returns_correct_waiting_time_without_history
(
self
):
throttle
=
SimpleRateThrottle
()
throttle
.
num_requests
=
1
throttle
.
duration
=
60
throttle
.
history
=
[]
waiting_time
=
throttle
.
wait
()
assert
isinstance
(
waiting_time
,
float
)
assert
waiting_time
==
30.0
def
test_wait_returns_none_if_there_are_no_available_requests
(
self
):
throttle
=
SimpleRateThrottle
()
throttle
.
num_requests
=
1
throttle
.
duration
=
60
throttle
.
now
=
throttle
.
timer
()
throttle
.
history
=
[
throttle
.
timer
()
for
_
in
range
(
3
)]
assert
throttle
.
wait
()
is
None
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