#NEWLINE# def test_addform_multiple_image( self ) : #NEWLINE# #INDENT# author = Author . objects . create ( name = 'Mark Twain' ) #NEWLINE# self . admin_login ( 'mtwain' , 'p@ssw0rd' , login_url = reverse ( 'admin:cropduster_article_add' ) ) #NEWLINE# browser = self . selenium #NEWLINE# browser . find_element_by_id ( 'id_title' ) . send_keys ( "A Connecticut Yankee in King Arthur's Court" ) #NEWLINE# browser . find_element_by_css_selector ( '#lead_image-group .rounded-button' ) . click ( ) #NEWLINE# with self . switch_to_popup_window ( ) : #NEWLINE# #INDENT# with self . visible_selector ( '#id_image' ) as el : #NEWLINE# #INDENT# el . send_keys ( os . path . join ( author . TEST_IMG_DIR , 'img.jpg' ) ) #NEWLINE# #UNINDENT# with self . clickable_selector ( '#upload-button' ) as el : #NEWLINE# #INDENT# el . click ( ) #NEWLINE# #UNINDENT# with self . clickable_selector ( '#crop-button' ) as el : #NEWLINE# #INDENT# el . click ( ) #NEWLINE# #UNINDENT# with self . clickable_selector ( '#crop-button:not(.disabled)' ) as el : #NEWLINE# #INDENT# el . click ( ) #NEWLINE# #UNINDENT# #UNINDENT# with self . clickable_selector ( '#alt_image-group .rounded-button' ) as el : #NEWLINE# #INDENT# browser . execute_script ( ( 'window.scrollTo(0, %d)' % el . location [ 'y' ] ) ) #NEWLINE# el . click ( ) #NEWLINE# #UNINDENT# with self . switch_to_popup_window ( ) : #NEWLINE# #INDENT# with self . visible_selector ( '#id_image' ) as el : #NEWLINE# #INDENT# el . send_keys ( os . path . join ( self . TEST_IMG_DIR , 'img.png' ) ) #NEWLINE# #UNINDENT# with self . clickable_selector ( '#upload-button' ) as el : #NEWLINE# #INDENT# el . click ( ) #NEWLINE# #UNINDENT# with self . clickable_selector ( '#crop-button' ) as el : #NEWLINE# #INDENT# el . click ( ) #NEWLINE# #UNINDENT# #UNINDENT# browser . find_element_by_xpath ( ( '//select[@id="id_author"]/option[@value=%d]' % author . pk ) ) . click ( ) #NEWLINE# browser . find_element_by_xpath ( '//input[@value="Save and continue editing"]' ) . click ( ) #NEWLINE# article = Article . objects . all ( ) [ 0 ] #NEWLINE# lead_sizes = list ( Size . flatten ( Article . LEAD_IMAGE_SIZES ) ) #NEWLINE# alt_sizes = list ( Size . flatten ( Article . ALT_IMAGE_SIZES ) ) #NEWLINE# self . assertTrue ( article . lead_image . path . endswith ( '.jpg' ) ) #NEWLINE# self . assertEqual ( len ( article . lead_image . related_object . thumbs . all ( ) ) , len ( lead_sizes ) ) #NEWLINE# self . assertTrue ( article . alt_image . path . endswith ( '.png' ) ) #NEWLINE# self . assertEqual ( len ( article . alt_image . related_object . thumbs . all ( ) ) , len ( alt_sizes ) )