#NEWLINE# @ patch ( 'requests.get' ) #NEWLINE# def test_unregistered_app( self , r_get ) : #NEWLINE# #INDENT# 'An app without a signature raises a BadRequest exception, but with HTML payload' #NEWLINE# head = dict ( ) #NEWLINE# head [ 'content-type' ] = 'text/html; charset=utf-8' #NEWLINE# r_get . return_value = Mock ( status_code = 400 , text = 'oauth_problem=signature_method_rejected&oauth_problem_advice=No%20certificates%20have%20been%20registered%20for%20the%20consumer' , headers = head ) #NEWLINE# credentials = Mock ( base_url = '' ) #NEWLINE# xero = Xero ( credentials ) #NEWLINE# try : #NEWLINE# #INDENT# xero . contacts . all ( ) #NEWLINE# self . fail ( 'Should raise a XeroUnauthorized.' ) #NEWLINE# #UNINDENT# except XeroBadRequest as e : #NEWLINE# #INDENT# self . assertEqual ( str ( e ) , 'No certificates have been registered for the consumer' ) #NEWLINE# self . assertEqual ( e . errors [ 0 ] , 'signature_method_rejected' ) #NEWLINE# self . assertEqual ( e . response . status_code , 400 ) #NEWLINE# self . assertEqual ( e . response . text , 'oauth_problem=signature_method_rejected&oauth_problem_advice=No%20certificates%20have%20been%20registered%20for%20the%20consumer' ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . fail ( ( 'Should raise a XeroBadRequest, not %s' % credentials ) )