#NEWLINE# def test_get_value( self ) : #NEWLINE# #INDENT# throughput = 5000 #NEWLINE# search_result = { #NEWLINE# #INDENT# 'hits' : { #NEWLINE# #INDENT# 'hits' : [ { #NEWLINE# #INDENT# '_source' : { #NEWLINE# #INDENT# 'value' : throughput , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# self . es_mock . search = mock . MagicMock ( return_value = search_result ) #NEWLINE# self . metrics_store . open ( MetricsTests . TRIAL_TIMESTAMP , 'test' , 'defaults' ) #NEWLINE# expected_query = { #NEWLINE# #INDENT# 'query' : { #NEWLINE# #INDENT# 'bool' : { #NEWLINE# #INDENT# 'filter' : [ { #NEWLINE# #INDENT# 'term' : { #NEWLINE# #INDENT# 'trial-timestamp' : '20160131T000000Z' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'term' : { #NEWLINE# #INDENT# 'environment' : 'unittest' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'term' : { #NEWLINE# #INDENT# 'track' : 'test' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'term' : { #NEWLINE# #INDENT# 'track-setup' : 'defaults' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , { #NEWLINE# #INDENT# 'term' : { #NEWLINE# #INDENT# 'name' : 'indexing_throughput' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# actual_throughput = self . metrics_store . get_one ( 'indexing_throughput' ) #NEWLINE# self . es_mock . search . assert_called_with ( index = 'rally-2016' , doc_type = 'metrics' , body = expected_query ) #NEWLINE# self . assertEqual ( throughput , actual_throughput )