#NEWLINE# def test_close( mocker , coordinator ) : #NEWLINE# #INDENT# mocker . patch . object ( coordinator , '_maybe_auto_commit_offsets_sync' ) #NEWLINE# mocker . patch . object ( coordinator , '_handle_leave_group_response' ) #NEWLINE# mocker . patch . object ( coordinator , 'coordinator_unknown' , return_value = False ) #NEWLINE# coordinator . coordinator_id = 0 #NEWLINE# coordinator . generation = 1 #NEWLINE# cli = coordinator . _client #NEWLINE# mocker . patch . object ( cli , 'unschedule' ) #NEWLINE# mocker . patch . object ( cli , 'send' , return_value = Future ( ) . success ( 'foobar' ) ) #NEWLINE# mocker . patch . object ( cli , 'poll' ) #NEWLINE# coordinator . close ( ) #NEWLINE# assert ( coordinator . _maybe_auto_commit_offsets_sync . call_count == 1 ) #NEWLINE# cli . unschedule . assert_called_with ( coordinator . heartbeat_task ) #NEWLINE# coordinator . _handle_leave_group_response . assert_called_with ( 'foobar' ) #NEWLINE# assert ( coordinator . generation == ( - 1 ) ) #NEWLINE# assert ( coordinator . member_id == '' ) #NEWLINE# assert ( coordinator . rejoin_needed is True )