Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions azure/functions/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ def decode_multiple_events(cls, data: meta.Datum,
event = KafkaEvent(
body=parsed_data[i],
timestamp=parsed_timestamp_props[i],
key=cls._decode_typed_data(
parsed_key_props[i], python_type=str),
key=parsed_key_props[i],
partition=parsed_partition_props[i],
offset=parsed_offset_props[i],
topic=parsed_topic_props[i],
Expand Down
12 changes: 7 additions & 5 deletions tests/test_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class Kafka(unittest.TestCase):
MULTIPLE_KAFKA_TIMESTAMP_1 = "2020-06-20T05:06:25.945Z"
MULTIPLE_KAFKA_DATA_0 = '{"Offset":62,"Partition":1,"Topic":"message",'\
'"Timestamp":"2020-06-20T05:06:25.139Z","Value":"a", ' \
'"Headers":[{"Key":"test","Value":"1"}]}'
'"Headers":[{"Key":"test","Value":"1"}], ' \
'"Key" : "1"}'
MULTIPLE_KAFKA_DATA_1 = '{"Offset":63,"Partition":1,"Topic":"message",'\
'"Timestamp":"2020-06-20T05:06:25.945Z","Value":"a", ' \
'"Headers":[{"Key":"test2","Value":"2"}]}'
'"Headers":[{"Key":"test2","Value":"2"}], ' \
'"Key": "2"}'

def test_kafka_input_type(self):
check_input_type = (
Expand Down Expand Up @@ -238,10 +240,10 @@ def _generate_single_kafka_datum(self, datum_type='string'):
def _generate_multiple_kafka_data(self, data_type='json'):
data = '[{"Offset":62,"Partition":1,"Topic":"message",'\
'"Timestamp":"2020-06-20T05:06:25.139Z","Value":"a",' \
' "Headers":[{"Key":"test","Value":"1"}]},'\
' "Headers":[{"Key":"test","Value":"1"}], "Key": "1"},'\
' {"Offset":63,"Partition":1,"Topic":"message",'\
'"Timestamp":"2020-06-20T05:06:25.945Z","Value":"a", ' \
'"Headers":[{"Key":"test2","Value":"2"}]}]'
'"Headers":[{"Key":"test2","Value":"2"}], "Key": "2"}]'
if data_type == 'collection_bytes':
data = list(
map(lambda x: json.dumps(x).encode('utf-8'),
Expand Down Expand Up @@ -282,7 +284,7 @@ def _generate_single_trigger_metadatum(self):
}

def _generate_multiple_trigger_metadata(self):
key_array = [None, None]
key_array = ["1", "2"]
partition_array = [1, 2]
timestamp_array = ["2020-06-20T05:06:25.139Z",
"2020-06-20T05:06:25.945Z"]
Expand Down