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

All Samples(6)  |  Call(5)  |  Derive(0)  |  Import(1)

src/d/h/DHTBot-HEAD/dhtbot/test/extensions/test_rate_limiter.py   DHTBot(Download)
from twisted.trial import unittest
from twisted.python.monkey import MonkeyPatcher
 
from dhtbot.extensions import rate_limiter
from dhtbot.extensions.rate_limiter import \
    def test_can_consume_enoughTokens(self):
        tb = TokenBucket(10, 1)
        self.assertTrue(tb.can_consume(5))
 
    def test_can_consume_notEnoughTokens(self):
        tb = TokenBucket(10, 1)
        self.assertFalse(tb.can_consume(50))
 
    def test_can_consume_tokenRefill(self):
        tb = TokenBucket(10, 1)
    def test_consume_verifyTokenDecrease(self):
        tb = TokenBucket(10, 1)
        self.assertTrue(tb.consume(10))
        self.assertEquals(0, tb.tokens)