示例#1
0
 def test_clear(self):
     x = buckets.FastQueue()
     x.put(10)
     x.put(20)
     self.assertFalse(x.empty())
     x.clear()
     self.assertTrue(x.empty())
示例#2
0
 def test_wait(self):
     x = buckets.FastQueue()
     x.put(10)
     self.assertEqual(x.wait(), 10)
示例#3
0
 def test_items(self):
     x = buckets.FastQueue()
     x.put(10)
     x.put(20)
     self.assertListEqual([10, 20], list(x.items))
示例#4
0
 def test__get_queue_for_type(self):
     x = buckets.TaskBucket(task_registry={})
     x.buckets['foo'] = buckets.TokenBucketQueue(fill_rate=1)
     self.assertIs(x._get_queue_for_type('foo'), x.buckets['foo'].queue)
     x.buckets['bar'] = buckets.FastQueue()
     self.assertIs(x._get_queue_for_type('bar'), x.buckets['bar'])
示例#5
0
 def test__get_queue_for_type(self):
     x = buckets.TaskBucket(task_registry={})
     x.buckets["foo"] = buckets.TokenBucketQueue(fill_rate=1)
     self.assertIs(x._get_queue_for_type("foo"), x.buckets["foo"].queue)
     x.buckets["bar"] = buckets.FastQueue()
     self.assertIs(x._get_queue_for_type("bar"), x.buckets["bar"])
 def test_can_consume(self):
     x = buckets.FastQueue()
     self.assertTrue(x.can_consume())