#NEWLINE# @ mock . patch ( ( '%s.sahara_job_binaries.requests' % CTX ) ) #NEWLINE# @ mock . patch ( ( '%s.sahara_job_binaries.osclients' % CTX ) ) #NEWLINE# def test_download_and_save_lib( self , mock_osclients , mock_requests ) : #NEWLINE# #INDENT# mock_requests . get . content . return_value = 'some_binary_content' #NEWLINE# mock_sahara = mock_osclients . Clients ( mock . MagicMock ( ) ) . sahara ( ) #NEWLINE# mock_sahara . job_binary_internals . create . return_value = mock . MagicMock ( id = 42 ) #NEWLINE# sahara_ctx = sahara_job_binaries . SaharaJobBinaries ( mock_requests . context ) #NEWLINE# sahara_ctx . context [ 'tenants' ] [ '0' ] [ 'sahara' ] = { #NEWLINE# #INDENT# 'mains' : [ ] , #NEWLINE# #UNINDENT# } #NEWLINE# sahara_ctx . context [ 'tenants' ] [ '0' ] [ 'sahara' ] [ 'libs' ] = [ ] #NEWLINE# sahara_ctx . download_and_save_lib ( sahara = mock_sahara , lib_type = 'mains' , name = 'test_binary' , download_url = 'http://somewhere' , tenant_id = '0' ) #NEWLINE# sahara_ctx . download_and_save_lib ( sahara = mock_sahara , lib_type = 'libs' , name = 'test_binary_2' , download_url = 'http://somewhere' , tenant_id = '0' ) #NEWLINE# mock_requests . get . assert_called_once_with ( 'http://somewhere' )