#NEWLINE# @ patch ( 'nefertari.elasticsearch.ES.build_search_params' ) #NEWLINE# @ patch ( 'nefertari.elasticsearch.ES.api.search' ) #NEWLINE# def test_aggregation( self , mock_search , mock_build ) : #NEWLINE# #INDENT# mock_search . return_value = { #NEWLINE# #INDENT# 'aggregations' : { #NEWLINE# #INDENT# 'foo' : 1 , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# mock_build . return_value = { #NEWLINE# #INDENT# 'size' : 1 , #NEWLINE# 'from_' : 2 , #NEWLINE# 'sort' : 3 , #NEWLINE# 'body' : { #NEWLINE# #INDENT# 'query' : 'query1' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# obj = es . ES ( 'Foo' , 'foondex' ) #NEWLINE# resp = obj . aggregate ( _aggregations_params = { #NEWLINE# #INDENT# 'zoo' : 5 , #NEWLINE# #UNINDENT# } , param1 = 6 ) #NEWLINE# assert ( mock_build == { #NEWLINE# #INDENT# 'foo' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# mock_build . assert_called_once_with ( { #NEWLINE# #INDENT# '_limit' : 0 , #NEWLINE# 'param1' : 6 , #NEWLINE# #UNINDENT# } ) #NEWLINE# mock_search . assert_called_once_with ( search_type = 'count' , body = { #NEWLINE# #INDENT# 'aggregations' : { #NEWLINE# #INDENT# 'zoo' : 5 , #NEWLINE# #UNINDENT# } , #NEWLINE# 'query' : 'query1' , #NEWLINE# #UNINDENT# } )