示例#1
0
 def test_can_consume_tokenRefill(self):
     tb = TokenBucket(10, 1)
     self.assertFalse(tb.can_consume(50))
     self.clock.set(40)
     self.assertFalse(tb.can_consume(50))
示例#2
0
 def test_can_consume_enoughTokens(self):
     tb = TokenBucket(10, 1)
     self.assertTrue(tb.can_consume(5))
示例#3
0
 def test_can_consume_notEnoughTokens(self):
     tb = TokenBucket(10, 1)
     self.assertFalse(tb.can_consume(50))
示例#4
0
 def test_consume_verifyTokenDecrease(self):
     tb = TokenBucket(10, 1)
     self.assertTrue(tb.consume(10))
     self.assertEquals(0, tb.tokens)
示例#5
0
 def test_consume_notEnoughTokens(self):
     tb = TokenBucket(10, 1)
     self.assertFalse(tb.consume(100))
     self.assertEquals(10, tb.tokens)
示例#6
0
 def test_can_consume_tokenRefill(self):
     tb = TokenBucket(10, 1)
     self.assertFalse(tb.can_consume(50))
     self.clock.set(40)
     self.assertFalse(tb.can_consume(50))
示例#7
0
 def test_can_consume_notEnoughTokens(self):
     tb = TokenBucket(10, 1)
     self.assertFalse(tb.can_consume(50))
示例#8
0
 def test_can_consume_enoughTokens(self):
     tb = TokenBucket(10, 1)
     self.assertTrue(tb.can_consume(5))
示例#9
0
 def test_consume_notEnoughTokens(self):
     tb = TokenBucket(10, 1)
     self.assertFalse(tb.consume(100))
     self.assertEquals(10, tb.tokens)
示例#10
0
 def test_consume_verifyTokenDecrease(self):
     tb = TokenBucket(10, 1)
     self.assertTrue(tb.consume(10))
     self.assertEquals(0, tb.tokens)