#NEWLINE# def test_create_image_and_respond( self ) : #NEWLINE# #INDENT# url = reverse ( 'api:project_media' , kwargs = { #NEWLINE# #INDENT# 'project_id' : self . project . id , #NEWLINE# 'contribution_id' : self . contribution . id , #NEWLINE# #UNINDENT# } ) #NEWLINE# data = { #NEWLINE# #INDENT# 'name' : 'A test image' , #NEWLINE# 'description' : 'Test image description' , #NEWLINE# 'file' : get_image ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# request = self . factory . post ( url , data ) #NEWLINE# request . user = self . admin #NEWLINE# view = MediaAbstractAPIView ( ) #NEWLINE# view . request = request #NEWLINE# response = self . render ( view . create_and_respond ( request , self . contribution ) ) #NEWLINE# response_json = json . loads ( response . content ) #NEWLINE# self . assertEqual ( response_json . get ( 'name' ) , data . get ( 'name' ) ) #NEWLINE# self . assertEqual ( response_json . get ( 'description' ) , data . get ( 'description' ) ) #NEWLINE# self . assertEqual ( response_json . get ( 'creator' ) . get ( 'display_name' ) , request . user . display_name ) #NEWLINE# self . assertEqual ( response_json . get ( 'file_type' ) , 'ImageFile' ) #NEWLINE# self . assertIsNotNone ( response_json . get ( 'url' ) )