#NEWLINE# @ mock . patch ( 'simple_elasticsearch.models.BlogPost.get_document' ) #NEWLINE# @ mock . patch ( 'simple_elasticsearch.mixins.Elasticsearch.bulk' ) #NEWLINE# def test__bulk_index_get_document( self , mock_bulk , mock_get_document ) : #NEWLINE# #INDENT# mock_bulk . return_value = mock_get_document . return_value = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# queryset_count = BlogPost . get_queryset ( ) . count ( ) #NEWLINE# BlogPost . bulk_index ( ) #NEWLINE# self . assertTrue ( ( mock_get_document . call_count == ( queryset_count - 1 ) ) ) #NEWLINE# bulk_times = ( int ( ( queryset_count / BlogPost . get_bulk_index_limit ( ) ) ) + 1 ) #NEWLINE# self . assertTrue ( ( mock_bulk . call_count == bulk_times ) )