Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(9)  |  Call(9)  |  Derive(0)  |  Import(0)

src/d/h/DHTBot-HEAD/dhtbot/test/extensions/test_rate_limiter.py   DHTBot(Download)
    def test_consume_enoughBW(self):
        rl = RateLimiter()
        consumed = rl.consume(self.packet, self.address)
        self.assertTrue(consumed)
 
    def test_consume_overflowHostAndReset(self):
        rl = RateLimiter()
        # Consume first packet
        consumed = rl.consume(self.packet, self.address)
        self.assertTrue(consumed)
        # Drop second packet
        consumed = rl.consume(self.packet, self.address)
        self.assertFalse(consumed)
        # Wait a second for the limiter to reset
        self.clock.set(1)
        # And consume a packet again
        consumed = rl.consume(self.packet, self.address)
        rl = RateLimiter()
        # Consume first, second, and third packets
        consumed = rl.consume(self.packet, address1)
        self.assertTrue(consumed)
        consumed = rl.consume(self.packet, address2)