diff --git a/muranodashboard/tests/functional/base.py b/muranodashboard/tests/functional/base.py index 0b19caa15..dd9f07ea1 100644 --- a/muranodashboard/tests/functional/base.py +++ b/muranodashboard/tests/functional/base.py @@ -263,7 +263,7 @@ class UITestCase(testtools.TestCase): ui.WebDriverWait(self.driver, sec).until( EC.presence_of_element_located((method, value))) except exc.TimeoutException: - self.fail("Element {0} is not preset on the page".format(value)) + self.fail("Element {0} is not present on the page".format(value)) def check_element_not_on_page(self, method, value): self.driver.implicitly_wait(3) @@ -272,7 +272,7 @@ class UITestCase(testtools.TestCase): self.driver.find_element(method, value) except (exc.NoSuchElementException, exc.ElementNotVisibleException): present = False - self.assertFalse(present, u"Element {0} is preset on the page" + self.assertFalse(present, u"Element {0} is present on the page" " while it should't".format(value)) self.driver.implicitly_wait(30) @@ -282,7 +282,7 @@ class UITestCase(testtools.TestCase): ui.WebDriverWait(self.driver, sec).until( EC.presence_of_element_located(locator)) except exc.TimeoutException: - self.fail("Alert is not preset on the page") + self.fail("Alert is not present on the page") self.assertIn(message, self.driver.find_element(*locator).text) @@ -415,13 +415,15 @@ class ImageTestCase(PackageBase): glance_endpoint = cls.service_catalog.url_for(service_type='image') cls.glance = gclient.Client('1', endpoint=glance_endpoint, session=cls.keystone_client.session) + cls.images = [] cls.image_title = 'New Image ' + str(time.time()) cls.image = cls.upload_image(cls.image_title) @classmethod def tearDownClass(cls): super(ImageTestCase, cls).tearDownClass() - cls.glance.images.delete(cls.image.id) + for image in cls.images: + cls.glance.images.delete(image.id) @classmethod def upload_image(cls, title): @@ -437,6 +439,7 @@ class ImageTestCase(PackageBase): except Exception: logger.error("Unable to create or update image in Glance") raise + cls.images.append(image) return image def select_and_click_element(self, element): diff --git a/muranodashboard/tests/functional/sanity_check.py b/muranodashboard/tests/functional/sanity_check.py index 096d03be2..b61d494d9 100644 --- a/muranodashboard/tests/functional/sanity_check.py +++ b/muranodashboard/tests/functional/sanity_check.py @@ -764,12 +764,77 @@ class TestSuiteImage(base.ImageTestCase): self.go_to_submenu('Images') self.driver.find_element_by_xpath( c.DeleteImageMeta.format(self.image_title)).click() - self.driver.find_element_by_xpath(c.ConfirmDeletion).click() + with self.wait_for_page_reload(): + self.driver.find_element_by_xpath(c.ConfirmDeletion).click() + self.wait_for_alert_message() self.check_element_not_on_page(by.By.XPATH, c.TestImage.format(self.image_title)) - self.repair_image() + def test_delete_multiple_images(self): + """Test ability to delete multiple images. + + Scenario: + 1. Create 3 randomly named images. + 2. Navigate to Images page. + 3. For each randomly created image: + a. Select current image and click on "Delete Metadata". Each + image is deleted separately. + 4. Re-create 3 randomly named images. + 5. Refresh page. + 6. Select topmost checkbox and click on "Delete Metadata". All + images are deleted together. + 7. For each randomly created image: + a. Check that the current image was deleted. + 8. Check that ``self.image_title`` was also deleted. + """ + default_image_title = self.image_title + image_titles = [] + for i in range(3): + image_title = self.gen_random_resource_name('image') + image_titles.append(image_title) + self.upload_image(image_title) + + self.navigate_to('Manage') + self.go_to_submenu('Images') + + # Check each checkbox in the table and delete each image one by one. + for image_title in image_titles: + self.wait_element_is_clickable( + by.By.XPATH, c.DeleteImageMeta.format(image_title)).click() + with self.wait_for_page_reload(): + self.driver.find_element_by_xpath(c.ConfirmDeletion).click() + self.wait_for_alert_message() + self.check_element_not_on_page( + by.By.XPATH, c.TestImage.format(image_title)) + self.check_element_on_page( + by.By.XPATH, c.TestImage.format(default_image_title)) + + # Re-create 3 randomly named images. + image_titles = [] + for i in range(3): + image_title = self.gen_random_resource_name('image') + image_titles.append(image_title) + self.upload_image(image_title) + + # Check the topmost checkbox, then delete all images at the same time. + self.go_to_submenu('Images') + self.wait_element_is_clickable(by.By.CSS_SELECTOR, + 'label[for="ui-id-1"]').click() + self.wait_element_is_clickable(by.By.ID, + 'marked_images__action_delete').click() + with self.wait_for_page_reload(): + self.driver.find_element_by_xpath(c.ConfirmDeletion).click() + self.wait_for_alert_message() + + for image_title in image_titles: + self.check_element_not_on_page( + by.By.XPATH, c.TestImage.format(image_title)) + self.check_element_not_on_page( + by.By.XPATH, c.TestImage.format(default_image_title)) + + self.repair_image() # Restore the class-level image that was deleted. + class TestSuiteFields(base.FieldsTestCase): def test_check_domain_name_field_validation(self):