#NEWLINE# @ mock . patch ( 'elasticsearch.client.Elasticsearch.search' ) #NEWLINE# def test_search_returns_502_if_elasticsearch_fails( self , search_mock ) : #NEWLINE# #INDENT# search_mock . side_effect = Exception ( 'Not available' ) #NEWLINE# self . app . get ( '/models/test/search/' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , headers = self . headers , status = 502 )