Update to Payload namedtuples in consumer tests
This commit is contained in:
@@ -4,7 +4,7 @@ from . import unittest
|
|||||||
|
|
||||||
from kafka import SimpleConsumer, KafkaConsumer, MultiProcessConsumer
|
from kafka import SimpleConsumer, KafkaConsumer, MultiProcessConsumer
|
||||||
from kafka.common import (
|
from kafka.common import (
|
||||||
KafkaConfigurationError, FetchResponse, OffsetFetchResponse,
|
KafkaConfigurationError, FetchResponsePayload, OffsetFetchResponse,
|
||||||
FailedPayloadsError, OffsetAndMessage,
|
FailedPayloadsError, OffsetAndMessage,
|
||||||
NotLeaderForPartitionError, UnknownTopicOrPartitionError
|
NotLeaderForPartitionError, UnknownTopicOrPartitionError
|
||||||
)
|
)
|
||||||
@@ -54,7 +54,7 @@ class TestSimpleConsumer(unittest.TestCase):
|
|||||||
|
|
||||||
# Mock so that only the first request gets a valid response
|
# Mock so that only the first request gets a valid response
|
||||||
def not_leader(request):
|
def not_leader(request):
|
||||||
return FetchResponse(request.topic, request.partition,
|
return FetchResponsePayload(request.topic, request.partition,
|
||||||
NotLeaderForPartitionError.errno, -1, ())
|
NotLeaderForPartitionError.errno, -1, ())
|
||||||
|
|
||||||
client.send_fetch_request.side_effect = self.fail_requests_factory(not_leader)
|
client.send_fetch_request.side_effect = self.fail_requests_factory(not_leader)
|
||||||
@@ -75,7 +75,7 @@ class TestSimpleConsumer(unittest.TestCase):
|
|||||||
|
|
||||||
# Mock so that only the first request gets a valid response
|
# Mock so that only the first request gets a valid response
|
||||||
def unknown_topic_partition(request):
|
def unknown_topic_partition(request):
|
||||||
return FetchResponse(request.topic, request.partition,
|
return FetchResponsePayload(request.topic, request.partition,
|
||||||
UnknownTopicOrPartitionError.errno, -1, ())
|
UnknownTopicOrPartitionError.errno, -1, ())
|
||||||
|
|
||||||
client.send_fetch_request.side_effect = self.fail_requests_factory(unknown_topic_partition)
|
client.send_fetch_request.side_effect = self.fail_requests_factory(unknown_topic_partition)
|
||||||
@@ -128,7 +128,7 @@ class TestSimpleConsumer(unittest.TestCase):
|
|||||||
# Mock so that only the first request gets a valid response
|
# Mock so that only the first request gets a valid response
|
||||||
def fail_requests(payloads, **kwargs):
|
def fail_requests(payloads, **kwargs):
|
||||||
responses = [
|
responses = [
|
||||||
FetchResponse(payloads[0].topic, payloads[0].partition, 0, 0,
|
FetchResponsePayload(payloads[0].topic, payloads[0].partition, 0, 0,
|
||||||
(OffsetAndMessage(
|
(OffsetAndMessage(
|
||||||
payloads[0].offset + i,
|
payloads[0].offset + i,
|
||||||
"msg %d" % (payloads[0].offset + i))
|
"msg %d" % (payloads[0].offset + i))
|
||||||
|
Reference in New Issue
Block a user