#NEWLINE# def test_can_be_added_in_the_dashboard( self ) : #NEWLINE# #INDENT# fancy_page = factories . FancyPageFactory ( node__name = 'Sample Page' ) #NEWLINE# self . assertEquals ( fancy_page . image , None ) #NEWLINE# im = Image . new ( 'RGB' , ( 320 , 240 ) , 'red' ) #NEWLINE# ( __ , filename ) = tempfile . mkstemp ( suffix = '.jpg' , dir = TEMP_IMAGE_DIR ) #NEWLINE# im . save ( filename , 'JPEG' ) #NEWLINE# page = self . get ( reverse ( 'fp-dashboard:page-update' , args = ( fancy_page . id , ) ) ) #NEWLINE# settings_form = page . form #NEWLINE# settings_form [ 'image' ] = Upload ( filename ) #NEWLINE# list_page = settings_form . submit ( ) #NEWLINE# self . assertRedirects ( list_page , reverse ( 'fp-dashboard:page-list' ) ) #NEWLINE# upload_url = None #NEWLINE# for field in get_node_model ( ) . _meta . fields : #NEWLINE# #INDENT# if ( field . name == 'image' ) : #NEWLINE# #INDENT# upload_url = field . upload_to #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# pages_path = os . path . join ( settings . MEDIA_ROOT , upload_url ) #NEWLINE# fancy_page = FancyPage . objects . get ( id = fancy_page . id ) #NEWLINE# self . assertEquals ( fancy_page . image . path , os . path . join ( pages_path , filename . rsplit ( '/' ) [ ( - 1 ) ] ) )