<s> from openstack_dashboard . test . integration_tests import helpers <EOL> from openstack_dashboard . test . integration_tests . regions import messages <EOL> class TestImagesBasic ( helpers . TestCase ) : <EOL> """<STR_LIT>""" <EOL> IMAGE_NAME = helpers . gen_random_resource_name ( "<STR_LIT:image>" ) <EOL> @ property <EOL> def images_page ( self ) : <EOL> return self . home_pg . go_to_compute_imagespage ( ) <EOL> def image_create ( self , local_file = None ) : <EOL> images_page = self . images_page <EOL> if local_file : <EOL> images_page . create_image ( self . IMAGE_NAME , <EOL> image_source_type = '<STR_LIT:file>' , <EOL> image_file = local_file ) <EOL> else : <EOL> images_page . create_image ( self . IMAGE_NAME ) <EOL> self . assertTrue ( images_page . find_message_and_dismiss ( messages . INFO ) ) <EOL> self . assertFalse ( images_page . find_message_and_dismiss ( messages . ERROR ) ) <EOL> self . assertTrue ( images_page . is_image_present ( self . IMAGE_NAME ) ) <EOL> self . assertTrue ( images_page . is_image_active ( self . IMAGE_NAME ) ) <EOL> return images_page <EOL> def image_delete ( self ) : <EOL> images_page = self . images_page <EOL> images_page . delete_image ( self . IMAGE_NAME ) <EOL> self . assertTrue ( images_page . find_message_and_dismiss ( messages . SUCCESS ) ) <EOL> self . assertFalse ( images_page . find_message_and_dismiss ( messages . ERROR ) ) <EOL> self . assertFalse ( images_page . is_image_present ( self . IMAGE_NAME ) ) <EOL> def test_image_create_delete ( self ) : <EOL> """<STR_LIT>""" <EOL> self . image_create ( ) <EOL> self . image_delete ( ) <EOL> def test_image_create_delete_from_local_file ( self ) : <EOL> """<STR_LIT>""" <EOL> with helpers . gen_temporary_file ( ) as file_name : <EOL> self . image_create ( local_file = file_name ) <EOL> self . image_delete ( ) <EOL> def test_images_pagination ( self ) : <EOL> """<STR_LIT>""" <EOL> default_image_list = self . CONFIG . image . images_list <EOL> items_per_page = <NUM_LIT:1> <EOL> first_page_definition = { '<STR_LIT>' : True , '<STR_LIT>' : False , <EOL> '<STR_LIT>' : items_per_page , <EOL> '<STR_LIT>' : [ default_image_list [ <NUM_LIT:0> ] ] } <EOL> second_page_definition = { '<STR_LIT>' : True , '<STR_LIT>' : True , <EOL> '<STR_LIT>' : items_per_page , <EOL> '<STR_LIT>' : [ default_image_list [ <NUM_LIT:1> ] ] } <EOL> third_page_definition = { '<STR_LIT>' : False , '<STR_LIT>' : True , <EOL> '<STR_LIT>' : items_per_page , <EOL> '<STR_LIT>' : [ default_image_list [ <NUM_LIT:2> ] ] } <EOL> settings_page = self . home_pg . go_to_settings_usersettingspage ( ) <EOL> settings_page . change_pagesize ( items_per_page ) <EOL> settings_page . find_message_and_dismiss ( messages . SUCCESS ) <EOL> images_page = self . images_page <EOL> images_page . images_table . assert_definition ( first_page_definition ) <EOL> images_page . images_table . turn_next_page ( ) <EOL> images_page . images_table . assert_definition ( second_page_definition ) <EOL> images_page . images_table . turn_next_page ( ) <EOL> images_page . images_table . assert_definition ( third_page_definition ) <EOL> images_page . images_table . turn_prev_page ( ) <EOL> images_page . images_table . assert_definition ( second_page_definition ) <EOL> images_page . images_table . turn_prev_page ( ) <EOL> images_page . images_table . assert_definition ( first_page_definition ) <EOL> settings_page = self . home_pg . go_to_settings_usersettingspage ( ) <EOL> settings_page . change_pagesize ( ) <EOL> settings_page . find_message_and_dismiss ( messages . SUCCESS ) <EOL> def test_update_image_metadata ( self ) : <EOL> """<STR_LIT>""" <EOL> new_metadata = { '<STR_LIT>' : helpers . gen_random_resource_name ( "<STR_LIT:value>" ) , <EOL> '<STR_LIT>' : helpers . gen_random_resource_name ( "<STR_LIT:value>" ) } <EOL> with helpers . gen_temporary_file ( ) as file_name : <EOL> images_page = self . image_create ( local_file = file_name ) <EOL> images_page . add_custom_metadata ( self . IMAGE_NAME , new_metadata ) <EOL> results = images_page . check_image_details ( self . IMAGE_NAME , <EOL> new_metadata ) <EOL> self . image_delete ( ) <EOL> self . assertSequenceTrue ( results ) <EOL> def test_remove_protected_image ( self ) : <EOL> """<STR_LIT>""" <EOL> with helpers . gen_temporary_file ( ) as file_name : <EOL> images_page = self . image_create ( local_file = file_name ) <EOL> images_page . edit_image ( self . IMAGE_NAME , protected = True ) <EOL> self . assertTrue ( <EOL> images_page . find_message_and_dismiss ( messages . SUCCESS ) ) <EOL> with self . assertRaisesRegexp ( ValueError , '<STR_LIT>' ) : <EOL> images_page . delete_image_via_row_action ( self . IMAGE_NAME ) <EOL> images_page . delete_image ( self . IMAGE_NAME ) <EOL> self . assertFalse ( <EOL> images_page . find_message_and_dismiss ( messages . SUCCESS ) ) <EOL> self . assertTrue ( <EOL> images_page . find_message_and_dismiss ( messages . ERROR ) ) <EOL> self . assertTrue ( images_page . is_image_present ( self . IMAGE_NAME ) ) <EOL> images_page . edit_image ( self . IMAGE_NAME , protected = False ) <EOL> self . assertTrue ( <EOL> images_page . find_message_and_dismiss ( messages . SUCCESS ) ) <EOL> self . image_delete ( ) <EOL> class TestImagesAdvanced ( helpers . TestCase ) : <EOL> """<STR_LIT>""" <EOL> IMAGE_NAME = helpers . gen_random_resource_name ( "<STR_LIT:image>" ) <EOL> @ property <EOL> def images_page ( self ) : <EOL> return self . home_pg . go_to_compute_imagespage ( ) <EOL> def test_create_volume_from_image ( self ) : <EOL> """<STR_LIT>""" <EOL> images_page = self . images_page <EOL> source_image = self . CONFIG . image . images_list [ <NUM_LIT:0> ] <EOL> target_volume = "<STR_LIT>" . format ( source_image ) <EOL> volumes_page = images_page . create_volume_from_image ( <EOL> source_image , volume_name = target_volume ) <EOL> self . assertTrue ( <EOL> volumes_page . find_message_and_dismiss ( messages . INFO ) ) <EOL> self . assertFalse ( <EOL> volumes_page . find_message_and_dismiss ( messages . ERROR ) ) <EOL> self . assertTrue ( volumes_page . is_volume_present ( target_volume ) ) <EOL> self . assertTrue ( volumes_page . is_volume_status ( target_volume , <EOL> '<STR_LIT>' ) ) <EOL> volumes_page . delete_volume ( target_volume ) <EOL> volumes_page . find_message_and_dismiss ( messages . SUCCESS ) <EOL> volumes_page . find_message_and_dismiss ( messages . ERROR ) <EOL> self . assertTrue ( volumes_page . is_volume_deleted ( target_volume ) ) <EOL> def test_launch_instance_from_image ( self ) : <EOL> """<STR_LIT>""" <EOL> images_page = self . images_page <EOL> source_image = self . CONFIG . image . images_list [ <NUM_LIT:0> ] <EOL> target_instance = "<STR_LIT>" . format ( source_image ) <EOL> instances_page = images_page . launch_instance_from_image ( <EOL> source_image , target_instance ) <EOL> self . assertTrue ( <EOL> instances_page . find_message_and_dismiss ( messages . SUCCESS ) ) <EOL> self . assertFalse ( <EOL> instances_page . find_message_and_dismiss ( messages . ERROR ) ) <EOL> self . assertTrue ( instances_page . is_instance_active ( target_instance ) ) <EOL> actual_image_name = instances_page . get_image_name ( target_instance ) <EOL> self . assertEqual ( source_image , actual_image_name ) <EOL> instances_page . delete_instance ( target_instance ) <EOL> self . assertTrue ( <EOL> instances_page . find_message_and_dismiss ( messages . SUCCESS ) ) <EOL> self . assertFalse ( <EOL> instances_page . find_message_and_dismiss ( messages . ERROR ) ) <EOL> self . assertTrue ( instances_page . is_instance_deleted ( target_instance ) ) <EOL> class TestImagesAdmin ( helpers . AdminTestCase , TestImagesBasic ) : <EOL> """<STR_LIT>""" <EOL> IMAGE_NAME = helpers . gen_random_resource_name ( "<STR_LIT:image>" ) <EOL> @ property <EOL> def images_page ( self ) : <EOL> return self . home_pg . go_to_system_imagespage ( ) <EOL> def test_filter_images ( self ) : <EOL> """<STR_LIT>""" <EOL> images_list = self . CONFIG . image . images_list <EOL> images_page = self . images_page <EOL> images_page . images_table . filter ( images_list [ <NUM_LIT:0> ] ) <EOL> self . assertTrue ( images_page . is_image_present ( images_list [ <NUM_LIT:0> ] ) ) <EOL> for image in images_list [ <NUM_LIT:1> : ] : <EOL> self . assertFalse ( images_page . is_image_present ( image ) ) <EOL> nonexistent_image_name = "<STR_LIT>" . format ( self . IMAGE_NAME ) <EOL> images_page . images_table . filter ( nonexistent_image_name ) <EOL> self . assertEqual ( images_page . images_table . rows , [ ] ) <EOL> images_page . images_table . filter ( '<STR_LIT>' ) </s>
