#NEWLINE# def _mock_network_post_and_put( self , expected_results_api_url , expected_idle_api_url ) : #NEWLINE# #INDENT# subjob_done_event = Event ( ) #NEWLINE# setup_done_event = Event ( ) #NEWLINE# teardown_done_event = Event ( ) #NEWLINE# def _get_success_mock_response( ) : #NEWLINE# #INDENT# mock_response = MagicMock ( spec = requests . models . Response , create = True ) #NEWLINE# mock_response . status_code = http . client . OK #NEWLINE# return mock_response #NEWLINE# #UNINDENT# def fake_network_post( url , * args , **kwargs ) : #NEWLINE# #INDENT# if ( url == expected_results_api_url ) : #NEWLINE# #INDENT# subjob_done_event . set ( ) #NEWLINE# #UNINDENT# return _get_success_mock_response ( ) #NEWLINE# #UNINDENT# def fake_network_put( url , request_params , **kwargs ) : #NEWLINE# #INDENT# if ( url == expected_idle_api_url ) : #NEWLINE# #INDENT# if ( request_params [ 'slave' ] [ 'state' ] == SlaveState . SETUP_COMPLETED ) : #NEWLINE# #INDENT# setup_done_event . set ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( request_params [ 'slave' ] [ 'state' ] == SlaveState . IDLE ) : #NEWLINE# #INDENT# teardown_done_event . set ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return _get_success_mock_response ( ) #NEWLINE# #UNINDENT# self . mock_network . post = fake_network_post #NEWLINE# self . mock_network . put = fake_network_put #NEWLINE# self . mock_network . put_with_digest = fake_network_put #NEWLINE# return ( teardown_done_event , teardown_done_event , setup_done_event )