#NEWLINE# def test_bad_request( self , PredictService , flask_app ) : #NEWLINE# #INDENT# predict_service = PredictService ( mapping = [ ] ) #NEWLINE# model = Mock ( ) #NEWLINE# request = Mock ( ) #NEWLINE# with patch . object ( predict_service , 'do' ) as psd : #NEWLINE# #INDENT# with flask_app . test_request_context ( ) : #NEWLINE# #INDENT# bad_request = BadRequest ( ) #NEWLINE# bad_request . args = ( 'daniel' , ) #NEWLINE# psd . side_effect = bad_request #NEWLINE# resp = predict_service ( model , resp_data ) #NEWLINE# #UNINDENT# #UNINDENT# resp_data = json . loads ( resp . get_data ( as_text = True ) ) #NEWLINE# assert ( resp . status_code == 400 ) #NEWLINE# assert ( resp_data == { #NEWLINE# #INDENT# 'metadata' : { #NEWLINE# #INDENT# 'status' : 'ERROR' , #NEWLINE# 'error_code' : ( - 1 ) , #NEWLINE# 'error_message' : "BadRequest: ('daniel',)" , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } )