fixing the whitespaces

This commit is contained in:
Pravin Kamble 2023-08-21 00:21:23 +05:30
parent decd4b83e1
commit c10c92c59b
3 changed files with 2 additions and 5 deletions

View File

@ -95,14 +95,13 @@ class SimpleRateThrottle(BaseThrottle):
msg = "No default throttle rate set for '%s' scope" % self.scope
raise ImproperlyConfigured(msg)
def parse_rate(self,rate):
def parse_rate(self, rate):
"""
Given the request rate string, return a two tuple of:
<allowed number of requests>, <period of time in seconds>
"""
if rate is None:
return (None, None)
num, period = rate.split('/')
quantity, unit = parse_quantity_and_unit(period).values()
num_requests = int(num)

View File

@ -19,4 +19,4 @@ def parse_quantity_and_unit(quantity_unit_string):
else:
quantity_unit_dict['quantity'] = int(quantity_unit_string[:i])
quantity_unit_dict['unit'] = quantity_unit_string[i:]
return quantity_unit_dict
return quantity_unit_dict

View File

@ -470,10 +470,8 @@ class SimpleRateThrottleTests(TestCase):
def test_parse_quantity_and_unit_parses_correctly(self):
result = parse_quantity_and_unit("5min")
assert result == {'quantity': 5, 'unit': 'min'}
result = parse_quantity_and_unit("h")
assert result == {'quantity': 1, 'unit': 'h'}
result = parse_quantity_and_unit("123s")
assert result == {'quantity': 123, 'unit': 's'}