From f41e5f3e4befda52a20f072f85b807d77361e64d Mon Sep 17 00:00:00 2001 From: Eduard Iskandarov Date: Sat, 24 Jan 2015 00:30:50 +0300 Subject: async queue: refactored code; add one more test --- test/test_producer.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'test/test_producer.py') diff --git a/test/test_producer.py b/test/test_producer.py index b57dfd8..627178d 100644 --- a/test/test_producer.py +++ b/test/test_producer.py @@ -53,15 +53,29 @@ class TestKafkaProducer(unittest.TestCase): assert client.send_produce_request.called @patch('kafka.producer.base.Process') - def test_producer_batch_send_queue_overfilled(self, process_mock): + def test_producer_async_queue_overfilled_batch_send(self, process_mock): queue_size = 2 producer = Producer(MagicMock(), batch_send=True, - batch_send_queue_maxsize=queue_size) + async_queue_maxsize=queue_size) topic = b'test-topic' partition = 0 + message = b'test-message' + + with self.assertRaises(BatchQueueOverfilledError): + message_list = [message] * (queue_size + 1) + producer.send_messages(topic, partition, *message_list) + @patch('kafka.producer.base.Process') + def test_producer_async_queue_overfilled(self, process_mock): + queue_size = 2 + producer = Producer(MagicMock(), async=True, + async_queue_maxsize=queue_size) + + topic = b'test-topic' + partition = 0 message = b'test-message' + with self.assertRaises(BatchQueueOverfilledError): message_list = [message] * (queue_size + 1) producer.send_messages(topic, partition, *message_list) -- cgit v1.2.1