#NEWLINE# def test_upload( self ) : #NEWLINE# #INDENT# 'Handle a new file upload.' #NEWLINE# with open ( self . temp_name , 'rb' ) as f : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# 'upload' : f , #NEWLINE# #UNINDENT# } #NEWLINE# response = self . client . post ( self . url , data ) #NEWLINE# #UNINDENT# self . assertEqual ( response . status_code , 200 ) #NEWLINE# result = json . loads ( response . content . decode ( 'utf-8' ) ) #NEWLINE# filename = os . path . basename ( self . temp_name ) #NEWLINE# self . assertIn ( 'stored' , result ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'is_valid' : True , #NEWLINE# 'filename' : filename , #NEWLINE# 'url' : None , #NEWLINE# 'stored' : result [ 'stored' ] , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( result , expected )