#NEWLINE# @ patch ( 'requests.get' ) #NEWLINE# def test_forbidden( self , r_get ) : #NEWLINE# #INDENT# 'In case of an SSL failure, a Forbidden exception is raised' #NEWLINE# r_get . return_value = Mock ( status_code = 403 , text = 'The client SSL certificate was not valid.' ) #NEWLINE# credentials = Mock ( base_url = '' ) #NEWLINE# xero = Xero ( credentials ) #NEWLINE# try : #NEWLINE# #INDENT# xero . contacts . all ( ) #NEWLINE# self . fail ( 'Should raise a XeroForbidden.' ) #NEWLINE# #UNINDENT# except XeroForbidden as e : #NEWLINE# #INDENT# self . assertEqual ( str ( credentials ) , 'The client SSL certificate was not valid.' ) #NEWLINE# self . assertEqual ( e . response . status_code , 403 ) #NEWLINE# self . assertEqual ( e . response . text , 'The client SSL certificate was not valid.' ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# self . fail ( ( 'Should raise a XeroForbidden, not %s' % e ) )