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()
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()
def get_rate_limit(resource, limit=100, interval=60, unit=1): return RateLimit(kv, resource, limit=limit, interval=interval, unit=unit)