#NEWLINE# @ mock . patch ( ( '%s.sahara_output_data_sources.resource_manager.cleanup' % CTX ) ) #NEWLINE# @ mock . patch ( ( '%s.sahara_output_data_sources.osclients' % CTX ) ) #NEWLINE# def test_setup_and_cleanup_hdfs( self , mock_osclients , mock_cleanup ) : #NEWLINE# #INDENT# mock_sahara = mock_osclients . Clients ( mock . MagicMock ( ) ) . sahara ( ) #NEWLINE# mock_sahara . data_sources . create . return_value = mock . MagicMock ( id = 42 ) #NEWLINE# sahara_ctx = sahara_output_data_sources . SaharaOutputDataSources ( self . context ) #NEWLINE# sahara_ctx . generate_random_name = mock . Mock ( ) #NEWLINE# output_ds_crete_calls = [ ] #NEWLINE# for i in range ( self . tenants_num ) : #NEWLINE# #INDENT# output_ds_crete_calls . append ( mock . call ( name = sahara_ctx . generate_random_name . return_value , description = '' , data_source_type = 'hdfs' , url = 'hdfs://test_host/' ) ) #NEWLINE# #UNINDENT# sahara_ctx . setup ( ) #NEWLINE# mock_sahara . data_sources . create . assert_has_calls ( output_ds_crete_calls ) #NEWLINE# sahara_ctx . cleanup ( ) #NEWLINE# mock_cleanup . assert_called_once_with ( names = [ 'sahara.data_sources' ] , users = self . context [ 'users' ] )