def test_enqueue(self, mock_redis): queue = ReliableQueue(mock_redis) qname = md5(self.user_id + "_queue").hexdigest() mock_redis.pipeline.return_value.execute.return_value =\ 10, 1, 1, 10, 11 l = queue.enqueue(qname, self.uuid, self.data) self.assertEqual(l, 10)
def test_enqueue(self, mock_redis): queue = ReliableQueue(mock_redis) qname = md5(self.user_id + "_queue").hexdigest() mock_redis.pipeline.return_value.execute.return_value =\ 10, 1, 1, 10, 11 l = queue.enqueue(qname, self.uuid, self.data) self.assertEqual(l, 10)
def test_enqueue_queue_full(self, mock_redis): queue = ReliableQueue(mock_redis) qname = md5(self.user_id + "_queue").hexdigest() mock_redis.get.return_value = 1024 l = -1 with self.assertRaises(ERedisQueueFull) as ar: l = queue.enqueue(qname, self.uuid, self.data) self.assertEqual(l, -1) self.assertIsInstance(ar.exception, ERedisQueueFull)
def test_enqueue_timeout_error(self, mock_redis): queue = ReliableQueue(mock_redis) qname = md5(self.user_id + "_queue").hexdigest() mock_redis.pipeline.return_value.execute.side_effect = TimeoutError l = -1 with self.assertRaises(TimeoutError) as ar: l = queue.enqueue(qname, self.uuid, self.data) self.assertEqual(l, -1) self.assertIsInstance(ar.exception, TimeoutError)
def test_enqueue_queue_full(self, mock_redis): queue = ReliableQueue(mock_redis) qname = md5(self.user_id + "_queue").hexdigest() mock_redis.get.return_value = 1024 l = -1 with self.assertRaises(ERedisQueueFull) as ar: l = queue.enqueue(qname, self.uuid, self.data) self.assertEqual(l, -1) self.assertIsInstance(ar.exception, ERedisQueueFull)
def test_enqueue_timeout_error(self, mock_redis): queue = ReliableQueue(mock_redis) qname = md5(self.user_id + "_queue").hexdigest() mock_redis.pipeline.return_value.execute.side_effect = TimeoutError l = -1 with self.assertRaises(TimeoutError) as ar: l = queue.enqueue(qname, self.uuid, self.data) self.assertEqual(l, -1) self.assertIsInstance(ar.exception, TimeoutError)