11from unittest .mock import patch
22
3- from confluent_kafka .admin import ClusterMetadata , BrokerMetadata , TopicMetadata
3+ from confluent_kafka .admin import BrokerMetadata , ClusterMetadata , TopicMetadata
44
55from saluki .sniff import sniff
66
7+
78def test_sniff_with_two_partitions_in_a_topic ():
8- with patch ("saluki.sniff.AdminClient" ) as a , patch ("saluki.sniff.Consumer" ) as c , patch ("saluki.sniff.logger" ) as logger :
9+ with (
10+ patch ("saluki.sniff.AdminClient" ) as a ,
11+ patch ("saluki.sniff.Consumer" ) as c ,
12+ patch ("saluki.sniff.logger" ) as logger ,
13+ ):
914 fake_cluster_md = ClusterMetadata ()
1015 broker1 = BrokerMetadata ()
1116 broker1 .id = "id1"
@@ -14,16 +19,13 @@ def test_sniff_with_two_partitions_in_a_topic():
1419 fake_cluster_md .brokers = {0 : broker1 }
1520
1621 topic1 = TopicMetadata ()
17- topic1 .partitions = {0 :{}}
22+ topic1 .partitions = {0 : {}}
1823 topic2 = TopicMetadata ()
19- topic2 .partitions = {0 :{}, 1 :{}}
24+ topic2 .partitions = {0 : {}, 1 : {}}
2025
21- fake_cluster_md .topics = {
22- "topic1" : topic1 ,
23- "topic2" : topic2
24- }
26+ fake_cluster_md .topics = {"topic1" : topic1 , "topic2" : topic2 }
2527 a ().list_topics .return_value = fake_cluster_md
26- c ().get_watermark_offsets .return_value = 1 ,2
28+ c ().get_watermark_offsets .return_value = 1 , 2
2729 sniff ("whatever" )
2830
2931 brokers_call = logger .info .call_args_list [2 ]
@@ -38,4 +40,3 @@ def test_sniff_with_two_partitions_in_a_topic():
3840
3941 topic2_call2 = logger .info .call_args_list [8 ]
4042 assert "1 - low:1, high:2, num_messages:1" in topic2_call2 .args [0 ]
41-
0 commit comments