#NEWLINE# def test_handle_non_json_spi_response( self ) : #NEWLINE# #INDENT# orig_request = test_utils . build_request ( '/_ah/api/fake/path' ) #NEWLINE# spi_request = orig_request . copy ( ) #NEWLINE# spi_response = dispatcher . ResponseTuple ( 200 , [ ( 'Content-type' , 'text/plain' ) ] , 'This is an invalid response.' ) #NEWLINE# response = self . server . handle_spi_response ( orig_request , spi_request , spi_response , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , self . start_response ) #NEWLINE# error_json = { #NEWLINE# #INDENT# 'error' : { #NEWLINE# #INDENT# 'message' : 'Non-JSON reply: This is an invalid response.' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# body = json . dumps ( orig_request ) #NEWLINE# self . assert_http_match ( response , '500' , [ ( 'Content-Type' , 'application/json' ) , ( 'Content-Length' , ( '%d' % len ( body ) ) ) ] , body )