#NEWLINE# def test_get_or_create_user_auth_backend( self ) : #NEWLINE# #INDENT# 'Testing the PUT review-requests/<id>/draft/ API\n        with AuthBackend.get_or_create_user failure\n        ' #NEWLINE# class SandboxAuthBackend ( AuthBackend ) : #NEWLINE# #INDENT# backend_id = 'test-id' #NEWLINE# name = 'test' #NEWLINE# def get_or_create_user( self , username , request = None , password = None ) : #NEWLINE# #INDENT# raise Exception #NEWLINE# #UNINDENT# #UNINDENT# backend = SandboxAuthBackend ( ) #NEWLINE# self . spy_on ( auth . get_backends , call_fake = ( lambda : [ backend ] ) ) #NEWLINE# self . spy_on ( ReviewRequest . is_mutable_by , call_fake = ( lambda x , y : True ) ) #NEWLINE# self . spy_on ( backend . get_or_create_user ) #NEWLINE# review_request = self . create_review_request ( submitter = self . user ) #NEWLINE# ReviewRequestDraft . create ( review_request ) #NEWLINE# rsp = self . api_put ( get_review_request_draft_url ( rsp , None ) , { #NEWLINE# #INDENT# 'target_people' : 'Target' , #NEWLINE# #UNINDENT# } , expected_status = 400 ) #NEWLINE# self . assertEqual ( rsp [ 'stat' ] , 'fail' ) #NEWLINE# self . assertTrue ( backend . get_or_create_user . called )