summaryrefslogtreecommitdiff
path: root/test/test_consumer_integration.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_consumer_integration.py')
-rw-r--r--test/test_consumer_integration.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/test_consumer_integration.py b/test/test_consumer_integration.py
index 78a8a3c..c1b2479 100644
--- a/test/test_consumer_integration.py
+++ b/test/test_consumer_integration.py
@@ -1,6 +1,9 @@
import logging
import os
import time
+from mock import patch
+import pytest
+import kafka.codec
from six.moves import xrange
import six
@@ -13,7 +16,7 @@ from kafka import (
from kafka.consumer.base import MAX_FETCH_BUFFER_SIZE_BYTES
from kafka.errors import (
ConsumerFetchSizeTooSmall, OffsetOutOfRangeError, UnsupportedVersionError,
- KafkaTimeoutError
+ KafkaTimeoutError, UnsupportedCodecError
)
from kafka.structs import (
ProduceRequestPayload, TopicPartition, OffsetAndTimestamp
@@ -25,6 +28,7 @@ from test.testutil import (
send_messages
)
+
def test_kafka_consumer(simple_client, topic, kafka_consumer_factory):
"""Test KafkaConsumer
"""
@@ -47,6 +51,23 @@ def test_kafka_consumer(simple_client, topic, kafka_consumer_factory):
kafka_consumer.close()
+def test_kafka_consumer_unsupported_encoding(
+ topic, kafka_producer_factory, kafka_consumer_factory):
+ # Send a compressed message
+ producer = kafka_producer_factory(compression_type="gzip")
+ fut = producer.send(topic, b"simple message" * 200)
+ fut.get(timeout=5)
+ producer.close()
+
+ # Consume, but with the related compression codec not available
+ with patch.object(kafka.codec, "has_gzip") as mocked:
+ mocked.return_value = False
+ consumer = kafka_consumer_factory(auto_offset_reset='earliest')
+ error_msg = "Libraries for gzip compression codec not found"
+ with pytest.raises(UnsupportedCodecError, match=error_msg):
+ consumer.poll(timeout_ms=2000)
+
+
class TestConsumerIntegration(KafkaIntegrationTestCase):
maxDiff = None