Added test remove protected image

Updated imagespage with edit row action and added one test.

Implements blueprint: horizon-integration-tests-coverage

Change-Id: Ida270f89d7f86758ac5958b7ecf2adbda5be9d0d
This commit is contained in:
Yury Tregubov 2016-02-17 15:27:10 +03:00
parent 5d6003971f
commit d2b3cf9df9
2 changed files with 90 additions and 0 deletions
openstack_dashboard/test/integration_tests
pages/project/compute
tests

@ -52,6 +52,11 @@ class ImagesTable(tables.TableRegion):
("disk_config", "config_drive")
)
EDIT_IMAGE_FORM_FIELDS = (
"name", "description", "disk_format", "minimum_disk",
"minimum_ram", "public", "protected"
)
@tables.bind_table_action('create')
def create_image(self, create_button):
create_button.click()
@ -82,6 +87,17 @@ class ImagesTable(tables.TableRegion):
metadata_button.click()
return forms.MetadataFormRegion(self.driver, self.conf)
@tables.bind_row_action('delete')
def delete_image_via_row_action(self, delete_button, row):
delete_button.click()
return forms.BaseFormRegion(self.driver, self.conf)
@tables.bind_row_action('edit')
def edit_image(self, edit_button, row):
edit_button.click()
return forms.FormRegion(self.driver, self.conf,
field_mappings=self.EDIT_IMAGE_FORM_FIELDS)
@tables.bind_row_anchor_column(IMAGES_TABLE_NAME_COLUMN)
def go_to_image_description_page(self, row_link, row):
row_link.click()
@ -152,6 +168,41 @@ class ImagesPage(basepage.BaseNavigationPage):
matches.append(True)
return matches
def edit_image(self, name, new_name=None, description=None,
minimum_disk=None, minimum_ram=None,
public=None, protected=None):
row = self._get_row_with_image_name(name)
confirm_edit_images_form = self.images_table.edit_image(row)
if new_name is not None:
confirm_edit_images_form.name.text = new_name
if description is not None:
confirm_edit_images_form.description.text = description
if minimum_disk is not None:
confirm_edit_images_form.minimum_disk.value = minimum_disk
if minimum_ram is not None:
confirm_edit_images_form.minimum_ram.value = minimum_ram
if public is True:
confirm_edit_images_form.public.mark()
elif public is False:
confirm_edit_images_form.public.unmark()
if protected is True:
confirm_edit_images_form.protected.mark()
elif protected is False:
confirm_edit_images_form.protected.unmark()
confirm_edit_images_form.submit()
def delete_image_via_row_action(self, name):
row = self._get_row_with_image_name(name)
delete_image_form = self.images_table.delete_image_via_row_action(row)
delete_image_form.submit()
def is_image_present(self, name):
return bool(self._get_row_with_image_name(name))

@ -141,6 +141,45 @@ class TestImagesBasic(helpers.TestCase):
self.image_delete()
self.assertSequenceTrue(results) # custom matcher
def test_remove_protected_image(self):
"""tests that protected image is not deletable
* logs in as admin user
* creates image from locally downloaded file
* verifies the image appears in the images table as active
* marks 'Protected' checkbox
* verifies that edit action was successful
* verifies that delete action is not available in the list
* tries to delete the image
* verifies that exception is generated for the protected image
* unmarks 'Protected' checkbox
* deletes the image
* verifies the image does not appear in the table after deletion
"""
with helpers.gen_temporary_file() as file_name:
images_page = self.image_create(local_file=file_name)
images_page.edit_image(self.IMAGE_NAME, protected=True)
self.assertTrue(
images_page.find_message_and_dismiss(messages.SUCCESS))
# Check that Delete action is not available in the action list.
# The below action will generate exception since the bind fails.
# But only ValueError with message below is expected here.
with self.assertRaisesRegexp(ValueError, 'Could not bind method'):
images_page.delete_image_via_row_action(self.IMAGE_NAME)
# Try to delete image. That should not be possible now.
images_page.delete_image(self.IMAGE_NAME)
self.assertFalse(
images_page.find_message_and_dismiss(messages.SUCCESS))
self.assertTrue(
images_page.find_message_and_dismiss(messages.ERROR))
self.assertTrue(images_page.is_image_present(self.IMAGE_NAME))
images_page.edit_image(self.IMAGE_NAME, protected=False)
self.assertTrue(
images_page.find_message_and_dismiss(messages.SUCCESS))
self.image_delete()
class TestImagesAdvanced(helpers.TestCase):
"""Login as demo user"""