#NEWLINE# def test_should_save_only_fields_from_data_for_partial_update( self ) : #NEWLINE# #INDENT# serializer_one = CommentSerializer ( instance = self . get_comment ( ) , data = { #NEWLINE# #INDENT# 'title' : 'goodbye' , #NEWLINE# #UNINDENT# } , partial = True ) #NEWLINE# serializer_two = CommentSerializer ( instance = self . get_comment ( ) , data = { #NEWLINE# #INDENT# 'text' : 'moon' , #NEWLINE# #UNINDENT# } , partial = True ) #NEWLINE# serializer_three_kwargs = { #NEWLINE# #INDENT# 'instance' : self . get_comment ( ) , #NEWLINE# 'partial' : True , #NEWLINE# #UNINDENT# } #NEWLINE# if get_rest_framework_features ( ) [ 'uses_single_request_data_in_serializers' ] : #NEWLINE# #INDENT# serializer_three_kwargs [ 'data' ] = { #NEWLINE# #INDENT# 'attachment' : self . files [ 1 ] , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# serializer_three_kwargs . update ( { #NEWLINE# #INDENT# 'data' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'files' : { #NEWLINE# #INDENT# 'attachment' : self . files [ 1 ] , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# serializer_three = CommentSerializer ( ** serializer_three_kwargs ) #NEWLINE# self . assertTrue ( serializer_one . is_valid ( ) ) #NEWLINE# self . assertTrue ( serializer_two . is_valid ( ) ) #NEWLINE# self . assertTrue ( serializer_three . is_valid ( ) ) #NEWLINE# serializer_one . save ( ) #NEWLINE# serializer_two . save ( ) #NEWLINE# serializer_three . save ( ) #NEWLINE# fresh_instance = self . get_comment ( ) #NEWLINE# self . assertEqual ( fresh_instance . attachment . read ( ) , 'file two' . encode ( 'utf-8' ) ) #NEWLINE# self . assertEqual ( fresh_instance . text , 'moon' ) #NEWLINE# self . assertEqual ( fresh_instance . title , 'goodbye' )