@@ -8,17 +8,34 @@ def test_sniff_with_two_partitions_in_a_topic():
88 with patch ("saluki.sniff.AdminClient" ) as a , patch ("saluki.sniff.Consumer" ) as c , patch ("saluki.sniff.logger" ) as logger :
99 fake_cluster_md = ClusterMetadata ()
1010 broker1 = BrokerMetadata ()
11- broker2 = BrokerMetadata ()
12- fake_cluster_md .brokers = {0 : broker1 , 1 : broker2 }
11+ broker1 .id = "id1"
12+ broker1 .host = "mybroker"
13+ broker1 .port = 9093
14+ fake_cluster_md .brokers = {0 : broker1 }
1315
1416 topic1 = TopicMetadata ()
17+ topic1 .partitions = {0 :{}}
1518 topic2 = TopicMetadata ()
19+ topic2 .partitions = {0 :{}, 1 :{}}
1620
1721 fake_cluster_md .topics = {
1822 "topic1" : topic1 ,
1923 "topic2" : topic2
2024 }
21- a .list_topics .return_value = fake_cluster_md
25+ a ().list_topics .return_value = fake_cluster_md
26+ c ().get_watermark_offsets .return_value = 1 ,2
2227 sniff ("whatever" )
2328
24- # TODO
29+ brokers_call = logger .info .call_args_list [2 ]
30+
31+ assert "mybroker:9093/id1" in brokers_call .args [0 ]
32+
33+ topic1_call = logger .info .call_args_list [5 ]
34+ assert "0 - low:1, high:2, num_messages:1" in topic1_call .args [0 ]
35+
36+ topic2_call1 = logger .info .call_args_list [7 ]
37+ assert "0 - low:1, high:2, num_messages:1" in topic2_call1 .args [0 ]
38+
39+ topic2_call2 = logger .info .call_args_list [8 ]
40+ assert "1 - low:1, high:2, num_messages:1" in topic2_call2 .args [0 ]
41+
0 commit comments