def test_check_allow_delete_image_snapshots_for_non_admin(self): """Allow to delete image snapshots for non-admin user""" self.driver.get("{}{}".format(conf.get('BASE_URI'), "/project/instances")) if not helpers.check_element_exists(self.driver, By.LINK_TEXT, conf.get('default_vm_name')): raise Exception("Default vm '{}' was not found on Horizon " "Instance page".format( conf.get('default_vm_name'))) self.driver.find_element_by_link_text( conf.get('default_vm_name')).click() # looking for button self.driver.find_element_by_xpath( '//*[@id="content_body"]//a[@class=' '"btn btn-default btn-sm dropdown-toggle"]').click() self.vm_uuid = self.driver.current_url.split('/')[-2] self.driver.find_element_by_id( "instances__row_{}__action_snapshot".format(self.vm_uuid)).click() name_snapshot = Utils.gen_rand_string('snapshot') self.driver.find_element_by_id("id_name").send_keys(name_snapshot) self.driver.find_element_by_xpath( "//*[@value='Create Snapshot']").submit() self.driver.find_element_by_link_text(name_snapshot).click() self.image_snapshot_uuid = self.driver.current_url.split('/')[-2] # There is probably list action if helpers.check_element_exists( self.driver, By.CSS_SELECTOR, 'a.btn.btn-default.btn-sm.dropdown-toggle'): self.driver.find_element_by_css_selector( 'a.btn.btn-default.btn-sm.dropdown-toggle').click() self.assertTrue( helpers.check_element_exists( self.driver, By.ID, "image_snapshots__row_{}__action_delete".format( self.image_snapshot_uuid))) Utils.add_to_report( "Allow to delete image snapshots for non-admin user")
def test_button_image_create(self): """"Create Image" button available only for admin""" self.driver.get("{}{}".format(conf.get('BASE_URI'), "/project/images")) # Check there is something self.assertTrue( helpers.check_element_exists(self.driver, "xpath", '//*[contains(@id, "images__row")]'), "The page is not valid") self.assertFalse( helpers.check_element_exists(self.driver, By.ID, "images__action_create"), "Create Image button is available for non-admin") Utils.add_to_report("Create Image button available only for admin")
def check_murano_dashboard_is_available(self): self.driver.get("{}{}".format(conf.get('BASE_URI'), "/murano/environments/")) self.assertTrue( helpers.check_element_exists(self.driver, By.LINK_TEXT, "Murano"), "Murano dashboard isn't available") Utils.add_to_report("Murano dashboard is available")
def check_dns_dashboard_is_available(self): self.driver.get("{}{}".format(conf.get('BASE_URI'), "/project/dns_domains/")) self.assertTrue( helpers.check_element_exists(self.driver, By.LINK_TEXT, "DNS"), "Dns dashboard isn't available") Utils.add_to_report("Dns dashboard is available")
def test_image_description_is_read_only(self): """Image description is read-only for non-admin Need to have an image""" self.driver.get("{}{}".format(conf.get('BASE_URI'), "/project/images")) # Check there is something assert helpers.check_element_exists( self.driver, "xpath", '//*[contains(@id, "images__row")]'),\ "There isn't any images" assert not helpers.check_element_exists( self.driver, "xpath", '//*[contains(@id, "images__row")]//button'), \ "Non-admin can change image description" Utils.add_to_report("Image description is read-only for non-admin")
def tearDown(self): if self.volume_uuid: self.driver.get("{}{}".format( conf.get('BASE_URI'), '/project/volumes/{}/'.format(self.volume_uuid))) self.driver.find_element_by_css_selector( 'a.btn.btn-default.btn-sm.dropdown-toggle').click() self.driver.find_element_by_id( "volumes__row_{}__action_delete".format( self.volume_uuid)).click() confirm_delete = self.driver.find_element_by_css_selector( 'a.btn.btn-primary') self.assertEqual(confirm_delete.text, "Delete Volume") confirm_delete.click() if self.image_snapshot_uuid: self.driver.get("{}{}".format( conf.get('BASE_URI'), '/project/image_snapshots/{}/'.format( self.image_snapshot_uuid))) # There is probably list action if helpers.check_element_exists( self.driver, By.CSS_SELECTOR, 'a.btn.btn-default.btn-sm.dropdown-toggle'): self.driver.find_element_by_css_selector( 'a.btn.btn-default.btn-sm.dropdown-toggle').click() self.driver.find_element_by_id( "image_snapshots__row_{}__action_delete".format( self.image_snapshot_uuid)).click() self.driver.find_element_by_link_text( "Delete Image Snapshot").click() if sys.exc_info()[0]: helpers.create_screenshot(self.driver, self._testMethodName) self.driver.close()
def test_check_empty_name_for_volume(self): """Check "empty" volume 'name' field Need to have an image """ self.driver.get("{}{}".format(conf.get('BASE_URI'), '/project/images')) # ToDo(den) do it better, choosing any image self.driver.find_element_by_xpath( "//*[@name='images__filter__q'][4]").click() if not helpers.check_element_exists(self.driver, By.LINK_TEXT, conf.get('default_image_name')): raise Exception("Default image '{}' was not found on Horizon " "Images page".format( conf.get('default_image_name'))) self.driver.find_element_by_link_text( conf.get('default_image_name')).click() # There is probably list action if helpers.check_element_exists( self.driver, By.CSS_SELECTOR, 'a.btn.btn-default.btn-sm.dropdown-toggle'): self.driver.find_element_by_css_selector( 'a.btn.btn-default.btn-sm.dropdown-toggle').click() self.driver.find_element_by_link_text("Create Volume").click() self.driver.find_element_by_id('id_name').clear() volume_description = Utils.gen_rand_string('volume') self.driver.find_element_by_id('id_description').send_keys( volume_description) self.driver.find_element_by_xpath("//input[@type='submit']").submit() # wait redirection to Volumes page self.wait.until( EC.visibility_of_element_located( (By.ID, "volumes__action_create"))) # get newest volume created volume = self.driver.find_elements_by_css_selector( "td.sortable.anchor.normal_column")[0] volume_name = volume.text # wait new volume is in stable state self.wait.until( EC.visibility_of_element_located( (By.ID, "volumes__row_{}__action_edit".format(volume_name)))) # check redirection self.assertIn("project/volumes", self.driver.current_url) volume = self.driver.find_elements_by_css_selector( "td.sortable.anchor.normal_column")[0] volume.click() self.volume_uuid = self.driver.current_url.split('/')[-2] # check name is equal to ID self.assertEqual(volume_name, self.volume_uuid) # check volume description is expected (verify it is our volume) overview = self.driver.find_element_by_css_selector( "div.info.row.detail") self.assertTrue(volume_description in overview.text) Utils.add_to_report("Check 'empty' volume 'name' field")