Exemple #1
0
 def test_rate(self):
     conn = get_fakeredis()
     limit = RateLimit(conn, 'banana', limit=10)
     assert limit.check()
     limit.update()
     assert limit.check()
     for _ in range(13):
         limit.update()
     assert not limit.check()
Exemple #2
0
 def test_rate(self):
     conn = get_fakeredis()
     limit = RateLimit(conn, "banana", limit=10)
     assert limit.check()
     limit.update()
     assert limit.check()
     for num in range(13):
         assert num + 2 == limit.update()
     assert not limit.check()
Exemple #3
0
def get_rate_limit(resource, limit=100, interval=60, unit=1):
    return RateLimit(kv, resource, limit=limit, interval=interval, unit=unit)