File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -397,3 +397,20 @@ def test_allow_request_returns_true_if_key_is_none(self):
397
397
throttle .rate = 'some rate'
398
398
throttle .get_cache_key = lambda * args : None
399
399
assert throttle .allow_request (request = {}, view = {}) is True
400
+
401
+ def test_wait_returns_correct_waiting_time_without_history (self ):
402
+ throttle = SimpleRateThrottle ()
403
+ throttle .num_requests = 1
404
+ throttle .duration = 60
405
+ throttle .history = []
406
+ waiting_time = throttle .wait ()
407
+ assert isinstance (waiting_time , float )
408
+ assert waiting_time == 30.0
409
+
410
+ def test_wait_returns_none_if_there_are_no_available_requests (self ):
411
+ throttle = SimpleRateThrottle ()
412
+ throttle .num_requests = 1
413
+ throttle .duration = 60
414
+ throttle .now = throttle .timer ()
415
+ throttle .history = [throttle .timer () for _ in range (3 )]
416
+ assert throttle .wait () is None
You can’t perform that action at this time.
0 commit comments