#NEWLINE# @ patch ( 'nefertari.elasticsearch.partial' ) #NEWLINE# @ patch ( 'nefertari.elasticsearch.ES.prep_bulk_documents' ) #NEWLINE# @ patch ( 'nefertari.elasticsearch.ES.process_chunks' ) #NEWLINE# def test_bulk( self , mock_proc , mock_prep , mock_part ) : #NEWLINE# #INDENT# obj = es . ES ( 'Foo' , 'foondex' , chunk_size = 1 ) #NEWLINE# docs = [ { #NEWLINE# #INDENT# '_op_type' : 'index' , #NEWLINE# '_id' : 'story1' , #NEWLINE# '_source' : { #NEWLINE# #INDENT# '_type' : 'Story' , #NEWLINE# 'id' : 'story1' , #NEWLINE# 'timestamp' : 1 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# '_op_type' : 'index' , #NEWLINE# '_id' : 'story2' , #NEWLINE# '_source' : { #NEWLINE# #INDENT# '_type' : 'Story' , #NEWLINE# 'id' : 'story2' , #NEWLINE# 'timestamp' : 2 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] #NEWLINE# mock_prep . return_value = docs #NEWLINE# obj . _bulk ( 'index' , mock_part ) #NEWLINE# mock_prep . assert_called_once_with ( 'index' , docs ) #NEWLINE# mock_part . assert_called_once_with ( es . _bulk_body , request = None ) #NEWLINE# mock_proc . assert_called_once_with ( documents = [ { #NEWLINE# #INDENT# '_id' : 'story1' , #NEWLINE# '_op_type' : 'index' , #NEWLINE# '_timestamp' : 1 , #NEWLINE# '_source' : { #NEWLINE# #INDENT# 'timestamp' : 1 , #NEWLINE# '_type' : 'Story' , #NEWLINE# 'id' : 'story1' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# '_id' : 'story2' , #NEWLINE# '_op_type' : 'index' , #NEWLINE# '_timestamp' : 2 , #NEWLINE# '_source' : { #NEWLINE# #INDENT# 'timestamp' : 2 , #NEWLINE# '_type' : 'Story' , #NEWLINE# 'id' : 'story2' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , operation = mock_part ( ) )