#NEWLINE# @ mock . patch ( 'framework.auth.cas.CasClient.revoke_tokens' ) #NEWLINE# def test_updating_one_field_should_not_blank_others_on_patch_update( self , mock_revoke ) : #NEWLINE# #INDENT# mock_revoke . return_value = True #NEWLINE# user1_token = self . user1_token #NEWLINE# new_name = 'The token formerly known as Prince' #NEWLINE# res = self . app . patch_json_api ( self . user1_token_url , { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# 'attributes' : { #NEWLINE# #INDENT# 'name' : new_name , #NEWLINE# 'scopes' : 'osf.full_write' , #NEWLINE# #UNINDENT# } , #NEWLINE# 'id' : self . user1_token . _id , #NEWLINE# 'type' : 'tokens' , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } , auth = self . user1 . auth ) #NEWLINE# user1_token . reload ( ) #NEWLINE# assert_equal ( res . status_code , 200 ) #NEWLINE# assert_dict_contains_subset ( { #NEWLINE# #INDENT# 'owner' : user1_token . owner . _id , #NEWLINE# 'name' : new_name , #NEWLINE# 'scopes' : '{}' . format ( user1_token . scopes ) , #NEWLINE# #UNINDENT# } , res . json [ 'data' ] [ 'attributes' ] ) #NEWLINE# assert_equal ( res . json [ 'data' ] [ 'id' ] , user1_token . _id )