def test_clear(self): x = buckets.FastQueue() x.put(10) x.put(20) self.assertFalse(x.empty()) x.clear() self.assertTrue(x.empty())
def test_wait(self): x = buckets.FastQueue() x.put(10) self.assertEqual(x.wait(), 10)
def test_items(self): x = buckets.FastQueue() x.put(10) x.put(20) self.assertListEqual([10, 20], list(x.items))
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__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())