@@ -37,10 +37,10 @@ def test_play_with_offsets():
3737 consumer_obj .consume .assert_called_with (2 ) # stop - start + 1
3838
3939 p_obj = p ()
40- call_1 = p_obj .produce . call_args_list [ 0 ]
41- assert call_1 . args == ( dest_topic , message_1_val , message_1_key )
42- call_2 = p_obj . produce . call_args_list [1 ]
43- assert call_2 . args == ( dest_topic , message_2_val , message_2_key )
40+ produce_batch_call = p_obj .produce_batch . call_args . args
41+ assert dest_topic == produce_batch_call [ 0 ]
42+ assert { 'key' : message_1_key , 'value' : message_1_val } in produce_batch_call [1 ]
43+ assert { 'key' : message_2_key , 'value' : message_2_val } in produce_batch_call [ 1 ]
4444
4545
4646def test_play_with_timestamps ():
@@ -64,9 +64,9 @@ def test_play_with_timestamps():
6464
6565 with patch ("saluki.play.Consumer" ) as c , patch ("saluki.play.Producer" ) as p :
6666 consumer_obj = c ()
67- consumer_obj .offsets_for_times .return_value = [
68- TopicPartition (src_topic , partition = 0 , offset = 2 ),
69- TopicPartition (src_topic , partition = 0 , offset = 3 ),
67+ consumer_obj .offsets_for_times .side_effect = [
68+ [ TopicPartition (src_topic , partition = 0 , offset = 2 )] ,
69+ [ TopicPartition (src_topic , partition = 0 , offset = 3 )]
7070 ]
7171 consumer_obj .consume .return_value = [message_1 , message_2 ]
7272
@@ -78,10 +78,10 @@ def test_play_with_timestamps():
7878 consumer_obj .consume .assert_called_with (2 ) # stop - start + 1
7979
8080 p_obj = p ()
81- call_1 = p_obj .produce . call_args_list [ 0 ]
82- assert call_1 . args == ( dest_topic , message_1_val , message_1_key )
83- call_2 = p_obj . produce . call_args_list [1 ]
84- assert call_2 . args == ( dest_topic , message_2_val , message_2_key )
81+ produce_batch_call = p_obj .produce_batch . call_args . args
82+ assert dest_topic == produce_batch_call [ 0 ]
83+ assert { 'key' : message_1_key , 'value' : message_1_val } in produce_batch_call [1 ]
84+ assert { 'key' : message_2_key , 'value' : message_2_val } in produce_batch_call [ 1 ]
8585
8686
8787def test_play_with_exception_when_consuming_consumer_still_closed ():
0 commit comments