#NEWLINE# def wait_for_app_to_launch_tasks( ) : #NEWLINE# #INDENT# return_values = [ False , None , True ] #NEWLINE# def get_mock_return_values( * args ) : #NEWLINE# #INDENT# val = return_values . pop ( ) #NEWLINE# if ( val is None ) : #NEWLINE# #INDENT# raise marathon_tools . NotFoundError #NEWLINE# #UNINDENT# return val #NEWLINE# #UNINDENT# with contextlib . nested ( mock . patch ( 'paasta_tools.marathon_tools.app_has_tasks' , autospec = True , side_effect = get_mock_return_values ) , mock . patch ( 'paasta_tools.marathon_tools.sleep' , autospec = True ) ) as ( mock_app_has_tasks , mock_sleep ) : #NEWLINE# #INDENT# marathon_tools . wait_for_app_to_launch_tasks ( mock . Mock ( ) , 'app_id' , 0 ) #NEWLINE# assert ( mock_app_has_tasks . call_count == 3 ) #NEWLINE# assert ( get_mock_return_values . call_count == 2 )