def test_below_threshold(self): """ acceptance test for main api call """ limiter = self.make_one() key1 = 'key1' assert limiter.gate(key1) is False
def test_release(self): limiter = self.make_one(0.01) key = 'k' ls = self.load_key(key, limiter.store, 6) loaded, howmany = ls[0] release_period = limiter.period * limiter.release clock = time.time() - loaded counter = count(1) slept = 0 while clock < release_period: i = next(counter) gate = limiter.gate(key) assert gate is True, "%s: Test #%s at %s, slept %s" %(gate, i, clock, slept) time.sleep(0.01) slept += 0.01 clock = time.time() - loaded gate = limiter.gate(key) assert gate is False, "Gate is still on" %gate
def test_exceed_threshold(self): limiter = self.make_one(0.01) key = 'k' self.load_key(key, limiter.store) assert limiter.gate(key) is True