mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-18 04:02:35 +03:00
fixing the whitespaces
This commit is contained in:
parent
decd4b83e1
commit
c10c92c59b
|
@ -95,14 +95,13 @@ class SimpleRateThrottle(BaseThrottle):
|
||||||
msg = "No default throttle rate set for '%s' scope" % self.scope
|
msg = "No default throttle rate set for '%s' scope" % self.scope
|
||||||
raise ImproperlyConfigured(msg)
|
raise ImproperlyConfigured(msg)
|
||||||
|
|
||||||
def parse_rate(self,rate):
|
def parse_rate(self, rate):
|
||||||
"""
|
"""
|
||||||
Given the request rate string, return a two tuple of:
|
Given the request rate string, return a two tuple of:
|
||||||
<allowed number of requests>, <period of time in seconds>
|
<allowed number of requests>, <period of time in seconds>
|
||||||
"""
|
"""
|
||||||
if rate is None:
|
if rate is None:
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
num, period = rate.split('/')
|
num, period = rate.split('/')
|
||||||
quantity, unit = parse_quantity_and_unit(period).values()
|
quantity, unit = parse_quantity_and_unit(period).values()
|
||||||
num_requests = int(num)
|
num_requests = int(num)
|
||||||
|
|
|
@ -19,4 +19,4 @@ def parse_quantity_and_unit(quantity_unit_string):
|
||||||
else:
|
else:
|
||||||
quantity_unit_dict['quantity'] = int(quantity_unit_string[:i])
|
quantity_unit_dict['quantity'] = int(quantity_unit_string[:i])
|
||||||
quantity_unit_dict['unit'] = quantity_unit_string[i:]
|
quantity_unit_dict['unit'] = quantity_unit_string[i:]
|
||||||
return quantity_unit_dict
|
return quantity_unit_dict
|
||||||
|
|
|
@ -470,10 +470,8 @@ class SimpleRateThrottleTests(TestCase):
|
||||||
def test_parse_quantity_and_unit_parses_correctly(self):
|
def test_parse_quantity_and_unit_parses_correctly(self):
|
||||||
result = parse_quantity_and_unit("5min")
|
result = parse_quantity_and_unit("5min")
|
||||||
assert result == {'quantity': 5, 'unit': 'min'}
|
assert result == {'quantity': 5, 'unit': 'min'}
|
||||||
|
|
||||||
result = parse_quantity_and_unit("h")
|
result = parse_quantity_and_unit("h")
|
||||||
assert result == {'quantity': 1, 'unit': 'h'}
|
assert result == {'quantity': 1, 'unit': 'h'}
|
||||||
|
|
||||||
result = parse_quantity_and_unit("123s")
|
result = parse_quantity_and_unit("123s")
|
||||||
assert result == {'quantity': 123, 'unit': 's'}
|
assert result == {'quantity': 123, 'unit': 's'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user