def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver)
        print 'Provider exists: ', self.provider_exists
        if self.provider_exists:
            try:
                # Delete provider
                print 'Provider is going to be deleted.'
                delete_provider(self.driver, Settings.provider_name)
                self.provider_exists = False
                time.sleep(BaseSettings.click_time_wait)
                search_field = self.driver.find_element_by_css_selector(
                    '[ng-model="generalSearch"]')
                search_field.clear()
                search_field.send_keys(Settings.provider_name)
                time.sleep(BaseSettings.search_time_wait)
                assert not element_exists(
                    self.driver,
                    xpath='//span[contains(text(), "%s")]' %
                    Settings.provider_name
                ), ('Error: Provider with name "%s" was not deleted, it still exists'
                    % Settings.provider_name)
                print 'Provider was deleted successfully.'
            except Exception as e:
                print 'Provider cannot be deleted. Error: "%s"' % e

        if self.project_exists:
            try:
                # Delete project
                print 'Project is going to be deleted.'
                delete_project(self.driver, Settings.project_name)
                self.project_exists = False
                time.sleep(BaseSettings.click_time_wait)
                search_field = self.driver.find_element_by_css_selector(
                    '[ng-model="generalSearch"]')
                search_field.clear()
                search_field.send_keys(Settings.project_name)
                time.sleep(BaseSettings.search_time_wait)
                if element_exists(self.driver,
                                  xpath='//a[contains(text(), "%s")]' %
                                  Settings.project_name):
                    self.project_exists = True
                print 'Project was deleted successfully.'
            except Exception as e:
                print 'Project cannot be deleted. Error: "%s"' % e

        if self.resource_exists:
            print 'Warning! Test cannot unlink resource "%s". It has to be unlinked manually.' % Settings.resource_name
        if self.provider_exists:
            print 'Warning! Test cannot delete provider "%s". It has to be deleted manually.' % Settings.provider_name
        if self.project_exists:
            print 'Warning! Test cannot delete project "%s". It has to be deleted manually.' % Settings.project_name

        self.driver.quit()
예제 #2
0
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
        if self.project_exists:
            try:
                # Remove project
                print 'Project is going to be removed.'
                remove_project(self.driver, self.project_name)
                self.project_exists = False
                print 'Project exists: ', self.project_exists
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.project_name)
                if element_exists(self.driver,
                                  xpath='//a[contains(text(), "%s")]' %
                                  self.project_name):
                    self.project_exists = True
                    print 'Project exists: ', self.project_exists
                print 'Project was removed successfully.'
            except Exception as e:
                print 'Project cannot be removed. Error: "%s"' % e

        if self.ssh_key_exists:
            try:
                # Remove ssh key
                print 'Ssh key is going to be removed.'
                remove_ssh_key(self.driver, self.key_name,
                               Settings.user_full_name)
                self.ssh_key_exists = False
                print 'SSH key exists: ', self.ssh_key_exists
                _search(self.driver, self.key_name)
                assert not element_exists(
                    self.driver,
                    xpath='//span[contains(text(), "%s")]' % self.key_name
                ), ('Error: SSH key with name "%s" was not removed, it still exists'
                    % self.key_name)
                print 'SSH key was removed successfully.'
            except Exception as e:
                print 'SSH key cannot be removed. Error: %s' % e

        if self.resource_exists:
            print 'Warning! Test cannot remove resource %s. It has to be removed manually.' % self.resource_name
        if self.project_exists:
            print 'Warning! Test cannot remove project %s. It has to be removed manually.' % self.project_name
        if self.ssh_key_exists:
            print 'Warning! Test cannot remove ssh key %s. It has to be deleted manually.' % self.key_name

        self.driver.quit()
예제 #3
0
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
            print 'Organization exists: ', self.organization_exists
        if self.organization_exists:
            try:
                # Remove organization
                print 'Organization is going to be removed.'
                remove_organization(self.driver, self.organization)
                self.organization_exists = False
                print 'Organization exists: ', self.organization_exists
                print 'Wait till go back to list option will be possible'
                WebDriverWait(
                    self.driver, Settings.
                    time_wait_to_go_back_to_list_of_organizations).until(
                        EC.element_to_be_clickable(
                            (By.CLASS_NAME, 'back-to-list')))
                _back_to_list(self.driver)
                print 'Existence check of removed organization'
                _search(self.driver,
                        self.organization,
                        css_selector='[ng-model="entityList.searchInput"]')
                assert not element_exists(
                    self.driver, link_text=self.organization
                ), ('Error: Organization with name "%s" was not removed, it still exists'
                    % self.organization)
                print 'Organization was removed successfully.'
            except Exception as e:
                print 'Organization cannot be removed. Error: "%s"' % e

        if self.organization_exists:
            print 'Warning! Test cannot remove organization "%s". It has to be removed manually.' % self.organization

        self.driver.quit()
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
        if self.project_exists:
            try:
                # Remove project
                print 'Project is going to be removed.'
                remove_project(self.driver, self.project_name)
                self.project_exists = False
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.project_name)
                if element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % self.project_name):
                    self.project_exists = True
                    print 'Project exists: ', self.project_exists
                print 'Project was removed successfully.'
            except Exception as e:
                print 'Project cannot be removed. Error: "%s"' % e

        if self.resource_exists:
            print 'Warning! Test cannot remove resource %s. It has to be removed manually.' % self.resource_name
        if self.project_exists:
            print 'Warning! Test cannot remove project %s. It has to be removed manually.' % self.project_name

        self.driver.quit()
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
        if self.project_exists:
            try:
                # Remove project
                print 'Project is going to be removed.'
                remove_project(self.driver, self.project_name)
                self.project_exists = False
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.project_name)
                if element_exists(self.driver,
                                  xpath='//a[contains(text(), "%s")]' %
                                  self.project_name):
                    self.project_exists = True
                    print 'Project exists: ', self.project_exists
                print 'Project was removed successfully.'
            except Exception as e:
                print 'Project cannot be removed. Error: "%s"' % e

        if self.resource_exists:
            print 'Warning! Test cannot remove resource %s. It has to be removed manually.' % self.resource_name
        if self.project_exists:
            print 'Warning! Test cannot remove project %s. It has to be removed manually.' % self.project_name

        self.driver.quit()
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
            print 'Organization exists: ', self.organization_exists
        if self.organization_exists:
            try:
                # Remove organization
                print 'Organization is going to be removed.'
                remove_organization(self.driver, self.organization)
                self.organization_exists = False
                print 'Organization exists: ', self.organization_exists
                print 'Wait till go back to list option will be possible'
                WebDriverWait(self.driver, Settings.time_wait_to_go_back_to_list_of_organizations).until(
                    EC.element_to_be_clickable((By.CLASS_NAME, 'back-to-list')))
                _back_to_list(self.driver)
                print 'Existence check of removed organization'
                _search(self.driver, self.organization, css_selector='[ng-model="entityList.searchInput"]')
                assert not element_exists(self.driver, link_text=self.organization), (
                    'Error: Organization with name "%s" was not removed, it still exists' % self.organization)
                print 'Organization was removed successfully.'
            except Exception as e:
                print 'Organization cannot be removed. Error: "%s"' % e

        if self.organization_exists:
            print 'Warning! Test cannot remove organization "%s". It has to be removed manually.' % self.organization

        self.driver.quit()
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver)
        print 'Organization exists: ', self.organization_exists
        if self.organization_exists:
            try:
                # Delete organization
                print 'Organization is going to be deleted.'
                delete_organization(self.driver, Settings.organization)
                self.organization_exists = False
                print 'Organization exists: ', self.organization_exists
                time.sleep(BaseSettings.click_time_wait)
                _back_to_list(self.driver)
                print 'Existence check of deleted organization'
                _search(self.driver, Settings.organization, css_selector='[ng-model="entityList.searchInput"]')
                assert not element_exists(self.driver, xpath='//span[contains(text(), "%s")]' % Settings.organization), (
                    'Error: Organization with name "%s" was not deleted, it still exists' % Settings.organization)
                print 'Organization was deleted successfully.'
            except Exception as e:
                print 'Organization cannot be deleted. Error: "%s"' % e

        if self.organization_exists:
            print 'Warning! Test cannot delete organization "%s". It has to be deleted manually.' % Settings.organization

        self.driver.quit()
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver)
        print 'Provider exists: ', self.provider_exists
        if self.provider_exists:
            try:
                # Delete provider
                print 'Provider is going to be deleted.'
                delete_provider(self.driver, Settings.provider_name)
                self.provider_exists = False
                time.sleep(BaseSettings.click_time_wait)
                search_field = self.driver.find_element_by_css_selector('[ng-model="generalSearch"]')
                search_field.clear()
                search_field.send_keys(Settings.provider_name)
                time.sleep(BaseSettings.search_time_wait)
                assert not element_exists(self.driver, xpath='//span[contains(text(), "%s")]' % Settings.provider_name), (
                    'Error: Provider with name "%s" was not deleted, it still exists' % Settings.provider_name)
                print 'Provider was deleted successfully.'
            except Exception as e:
                print 'Provider cannot be deleted. Error: "%s"' % e

        if self.project_exists:
            try:
                # Delete project
                print 'Project is going to be deleted.'
                delete_project(self.driver, Settings.project_name)
                self.project_exists = False
                time.sleep(BaseSettings.click_time_wait)
                search_field = self.driver.find_element_by_css_selector('[ng-model="generalSearch"]')
                search_field.clear()
                search_field.send_keys(Settings.project_name)
                time.sleep(BaseSettings.search_time_wait)
                if element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % Settings.project_name):
                    self.project_exists = True
                print 'Project was deleted successfully.'
            except Exception as e:
                print 'Project cannot be deleted. Error: "%s"' % e

        if self.resource_exists:
            print 'Warning! Test cannot unlink resource "%s". It has to be unlinked manually.' % Settings.resource_name
        if self.provider_exists:
            print 'Warning! Test cannot delete provider "%s". It has to be deleted manually.' % Settings.provider_name
        if self.project_exists:
            print 'Warning! Test cannot delete project "%s". It has to be deleted manually.' % Settings.project_name

        self.driver.quit()
예제 #9
0
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
        print 'Provider exists: ', self.provider_exists
        if self.provider_exists:
            try:
                # Remove provider
                print 'Provider is going to be removed.'
                remove_provider(self.driver, self.provider_name)
                self.provider_exists = False
                print 'Provider exists: ', self.provider_exists
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.provider_name)
                assert not element_exists(self.driver, xpath='//span[contains(text(), "%s")]' % self.provider_name), (
                    'Error: Provider with name "%s" was not removed, it still exists' % self.provider_name)
                print 'Provider was removed successfully.'
            except Exception as e:
                print 'Provider cannot be removed. Error: "%s"' % e

        if self.project_exists:
            try:
                # Remove project
                print 'Project is going to be removed.'
                remove_project(self.driver, self.project_name)
                self.project_exists = False
                print 'Project exists: ', self.project_exists
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.project_name)
                if element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % self.project_name):
                    self.project_exists = True
                print 'Project was removed successfully.'
            except Exception as e:
                print 'Project cannot be removed. Error: "%s"' % e

        if self.resource_exists:
            print 'Warning! Test cannot unlink resource "%s". It has to be unlinked manually.' % Settings.resource_name
        if self.provider_exists:
            print 'Warning! Test cannot remove provider "%s". It has to be removed manually.' % self.provider_name
        if self.project_exists:
            print 'Warning! Test cannot remove project "%s". It has to be removed manually.' % self.project_name

        self.driver.quit()
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
        if self.project_exists:
            try:
                # Remove project
                print 'Project is going to be removed.'
                remove_project(self.driver, self.project_name)
                self.project_exists = False
                print 'Project exists: ', self.project_exists
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.project_name)
                if element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % self.project_name):
                    self.project_exists = True
                    print 'Project exists: ', self.project_exists
                print 'Project was removed successfully.'
            except Exception as e:
                print 'Project cannot be removed. Error: "%s"' % e

        if self.ssh_key_exists:
            try:
                # Remove ssh key
                print 'Ssh key is going to be removed.'
                remove_ssh_key(self.driver, self.key_name, Settings.user_full_name)
                self.ssh_key_exists = False
                print 'SSH key exists: ', self.ssh_key_exists
                _search(self.driver, self.key_name)
                assert not element_exists(self.driver, xpath='//span[contains(text(), "%s")]' % self.key_name), (
                    'Error: SSH key with name "%s" was not removed, it still exists' % self.key_name)
                print 'SSH key was removed successfully.'
            except Exception as e:
                print 'SSH key cannot be removed. Error: %s' % e

        if self.resource_exists:
            print 'Warning! Test cannot remove resource %s. It has to be removed manually.' % self.resource_name
        if self.project_exists:
            print 'Warning! Test cannot remove project %s. It has to be removed manually.' % self.project_name
        if self.ssh_key_exists:
            print 'Warning! Test cannot remove ssh key %s. It has to be deleted manually.' % self.key_name

        self.driver.quit()
    def test_create_delete_project_provider_import_unlink_resource(self):
        # Login NC
        print '%s is going to be logged in.' % Settings.username
        login_nodeconductor(self.driver, Settings.username, Settings.password)
        username_idt_field = self.driver.find_element_by_class_name('user-name')
        assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.'
        print '%s was logged in successfully.' % Settings.username

        # Choose organization
        print 'Organization is going to be chosen.'
        choose_organization(self.driver, Settings.organization)
        print 'Organization was chosen successfully.'

        # Create project
        print 'Project is going to be created.'
        create_project(self.driver, Settings.project_name)
        time.sleep(BaseSettings.click_time_wait)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.project_name
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot create project "%s"' % Settings.project_name
        self.project_exists = True
        print 'Project exists: ', self.project_exists
        print 'Project was created successfully.'

        # Create provider
        print 'Provider is going to be created.'
        time.sleep(BaseSettings.click_time_wait)
        create_provider_digitalocean(self.driver, Settings.provider_name, Settings.provider_type_name,
                                     Settings.digitalocean_access_token)
        _search(self.driver, Settings.provider_name)
        print 'Find provider in list'
        xpath = '//span[contains(text(), "%s")]' % Settings.provider_name
        assert element_exists(self.driver, xpath=xpath), 'Error: Provider with name "%s" is not found' % Settings.provider_name
        self.provider_exists = True
        print 'Provider exists: ', self.provider_exists
        print 'Find In Sync state of created provider'
        try:
            WebDriverWait(self.driver, Settings.time_wait_for_provider_state).until(
                EC.presence_of_element_located((By.CSS_SELECTOR, ".status-circle.online")))
        except TimeoutException as e:
            print 'Error: Provider is not In Sync'
            raise e
        else:
            print 'Provider is in In Sync state'
        print 'Provider was created successfully.'

        # Import resource
        print 'Resource is going to be imported.'
        import_resource(self.driver, Settings.project_name, Settings.provider_name, Settings.category_name,
                        Settings.resource_name)
        _search(self.driver, Settings.resource_name)
        print 'Go to resource page'
        resource = self.driver.find_element_by_link_text(Settings.resource_name)
        resource.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Check imported resource existence'
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.resource_name
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot import resource "%s"' % Settings.resource_name
        self.resource_exists = True
        print 'Resource exists: ', self.resource_exists
        print 'Check imported resource state'
        xpath = '//div[contains(text(), "Online")]'
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Error: Imported resource "%s" is not online.' % Settings.resource_name
        print 'Imported resource is in online state'
        print 'Resource was imported successfully.'

        print '----- Cost is going to be checked----- '
        go_to_main_page(self.driver)
        costs = self.driver.find_element_by_link_text('Costs')
        costs.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Select resources tab'
        resources_list = self.driver.find_element_by_css_selector('[ng-class="{\'active\': row.selected && row.activeTab==\'resources\'}"]')
        resources_list.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Find row with the resource in a resource list'
        rows_list = self.driver.find_elements_by_css_selector('[ng-repeat="resource in row.resources"]')
        resource_cost_exists = False
        for row in rows_list:
            if Settings.resource_name in row.text:
                assert Settings.resource_cost in row.text, 'Error: Cannot find resource cost "%s" to check cost' % Settings.resource_cost
                resource_cost_exists = True
                print 'Resource cost "%s" was found on page' % Settings.resource_cost
        assert resource_cost_exists, 'Error: Cannot find resource with name "%s" ' % Settings.resource_name
        time.sleep(BaseSettings.click_time_wait)
        print '----- Cost was checked successfully----- '

        # Unlink resource
        print 'Resource is going to be unlinked.'
        unlink_resource(self.driver, Settings.project_name, Settings.resource_name)
        _search(self.driver, Settings.resource_name)
        print 'Check unlinked resource existence'
        assert not element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % Settings.resource_name), (
            'Error: Resource with name "%s" was not unlinked, it still exists' % Settings.resource_name)
        self.resource_exists = False
        print 'Resource exists: ', self.resource_exists
        print 'Resource was unlinked successfully.'
예제 #12
0
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver, name=self.__class__.__name__)
        if self.application_project_exists:
            try:
                # Remove application project
                print 'Application project is going to be removed.'
                remove_application_project(self.driver, self.project_name,
                                           self.application_project_name)
                self.application_project_exists = False
                print 'Application project exists: ', self.application_project_exists
                _search(self.driver, self.application_project_name)
                print 'Wait till application project will be removed'
                try:
                    WebDriverWait(
                        self.driver,
                        Settings.time_wait_to_remove_application).until(
                            EC.invisibility_of_element_located(
                                (By.XPATH, '//a[contains(text(), "%s")]' %
                                 self.application_project_name)))
                except TimeoutException as e:
                    print 'Error: Application project with name "%s" was not removed, it still exists' % self.application_project_name
                    raise e
                else:
                    print 'Application project was removed successfully.'
            except Exception as e:
                print 'Application project cannot be removed. Error: %s' % e

        if self.application_group_exists:
            try:
                # Remove application group
                print 'Application group is going to be removed.'
                remove_application_group(self.driver, self.project_name,
                                         self.application_group_name)
                self.application_group_exists = False
                print 'Application group exists: ', self.application_group_exists
                _search(self.driver, self.application_group_name)
                print 'Wait till application group will be removed'
                try:
                    WebDriverWait(
                        self.driver,
                        Settings.time_wait_to_remove_application).until(
                            EC.invisibility_of_element_located(
                                (By.XPATH, '//a[contains(text(), "%s")]' %
                                 self.application_group_name)))
                except TimeoutException as e:
                    print 'Error: Application group with name "%s" was not removed, it still exists' % self.application_group_name
                    raise e
                else:
                    print 'Application group was removed successfully.'
            except Exception as e:
                print 'Application group cannot be removed. Error: %s' % e

        if self.project_exists:
            try:
                # Remove project
                print 'Project is going to be removed.'
                remove_project(self.driver, self.project_name)
                self.project_exists = False
                print 'Project exists: ', self.project_exists
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, self.project_name)
                if element_exists(self.driver,
                                  xpath='//a[contains(text(), "%s")]' %
                                  self.project_name):
                    self.project_exists = True
                print 'Project was removed successfully.'
            except Exception as e:
                print 'Project cannot be removed. Error: "%s"' % e

        if self.application_project_exists:
            print 'Warning! Test cannot remove application project %s. It has to be removed manually.' % self.application_project_name
        if self.application_group_exists:
            print 'Warning! Test cannot remove application group %s. It has to be removed manually.' % self.application_group_name
        if self.project_exists:
            print 'Warning! Test cannot remove project %s. It has to be removed manually.' % self.project_name

        self.driver.quit()
예제 #13
0
    def test_import_unlink_resource(self):
        # Login NC
        print '%s is going to be logged in.' % Settings.username
        login_nodeconductor(self.driver, Settings.username, Settings.password)
        username_idt_field = self.driver.find_element_by_class_name('user-name')
        assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.'
        print '%s was logged in successfully.' % Settings.username

        # Choose organization
        print 'Organization is going to be chosen.'
        choose_organization(self.driver, Settings.organization)
        print 'Organization was chosen successfully.'

        # Add project
        print 'Project is going to be added.'
        add_project(self.driver, self.project_name)
        time.sleep(BaseSettings.click_time_wait)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % self.project_name
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot add project "%s"' % self.project_name
        self.project_exists = True
        print 'Project exists: ', self.project_exists
        print 'Project was added successfully.'

        # SAAS-1152
        # Add provider
        print 'Provider is going to be added.'
        time.sleep(BaseSettings.click_time_wait)
        add_provider_digitalocean(self.driver, self.provider_name, Settings.provider_type_name,
                                  Settings.digitalocean_access_token)
        _search(self.driver, self.provider_name)
        print 'Find provider in list'
        xpath = '//span[contains(text(), "%s")]' % self.provider_name
        assert element_exists(self.driver, xpath=xpath), 'Error: Provider with name "%s" is not found' % self.provider_name
        self.provider_exists = True
        print 'Provider exists: ', self.provider_exists
        print 'Find In Sync state of added provider'
        try:
            WebDriverWait(self.driver, Settings.time_wait_for_provider_state).until(
                EC.presence_of_element_located((By.CSS_SELECTOR, ".status-circle.online")))
        except TimeoutException as e:
            print 'Error: Provider is not In Sync'
            raise e
        else:
            print 'Provider is in In Sync state'
        print 'Provider was added successfully.'

        # Import resource
        print 'Resource is going to be imported.'
        imported = import_resource(self.driver, self.project_name, self.provider_name,
                                   Settings.category_name, Settings.resource_name, Settings.time_wait_available_resource_for_import)
        if not imported:
            return
        _search(self.driver, Settings.resource_name)
        print 'Go to resource page'
        resource = self.driver.find_element_by_link_text(Settings.resource_name)
        resource.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Check imported resource existence'
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.resource_name
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot import resource "%s"' % Settings.resource_name
        self.resource_exists = True
        print 'Resource exists: ', self.resource_exists
        print 'Check imported resource state'
        xpath = '//div[contains(text(), "Online")]'
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Error: Imported resource "%s" is not online.' % Settings.resource_name
        print 'Imported resource is in online state'
        print 'Resource was imported successfully.'

        # Blocker SAAS-1204
        # print '----- Cost is going to be checked----- '
        # go_to_main_page(self.driver)
        # costs = self.driver.find_element_by_link_text('Costs')
        # costs.click()
        # time.sleep(BaseSettings.click_time_wait)
        # print 'Select resources tab'
        # resources_list = self.driver.find_element_by_css_selector('ul.sort-list [ng-click="row.selected=true; row.activeTab=\'resources\'"]')
        # time.sleep(20)
        # resources_list.click()
        # time.sleep(BaseSettings.click_time_wait)
        # print 'Find row with the resource in a resource list'
        # rows_list = self.driver.find_elements_by_css_selector('[ng-repeat="resource in row.resources"]')
        # resource_cost_exists = False
        # for row in rows_list:
        #     if Settings.resource_name in row.text:
        #         assert Settings.resource_cost in row.text, 'Error: Cannot find resource cost "%s" to check cost' % Settings.resource_cost
        #         resource_cost_exists = True
        #         print 'Resource cost "%s" was found on page' % Settings.resource_cost
        # assert resource_cost_exists, 'Error: Cannot find resource with name "%s" ' % Settings.resource_name
        # time.sleep(BaseSettings.click_time_wait)
        # print '----- Cost was checked successfully----- '

        # Unlink resource
        print 'Resource is going to be unlinked.'
        unlink_resource(self.driver, self.project_name, Settings.resource_name)
        _search(self.driver, Settings.resource_name)
        print 'Check unlinked resource existence'
        assert not element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % Settings.resource_name), (
            'Error: Resource with name "%s" was not unlinked, it still exists' % Settings.resource_name)
        self.resource_exists = False
        print 'Resource exists: ', self.resource_exists
        print 'Resource was unlinked successfully.'
    def test_create_delete_project_key_resource(self):
        # Login NC
        print '%s is going to be logged in.' % Settings.username
        login_nodeconductor(self.driver, Settings.username, Settings.password)
        username_idt_field = self.driver.find_element_by_class_name('user-name')
        assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.'
        print '%s was logged in successfully.' % Settings.username

        # Choose organization
        print 'Organization is going to be chosen.'
        choose_organization(self.driver, Settings.organization)
        print 'Organization was chosen successfully.'

        # Create project
        print 'Project is going to be created.'
        create_project(self.driver, Settings.project_name)
        time.sleep(BaseSettings.click_time_wait)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.project_name
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot create project "%s"' % Settings.project_name
        self.project_exists = True
        print 'Project exists: ', self.project_exists
        print 'Project was created successfully.'

        # Create ssh key
        print 'SSH key is going to be created.'
        time.sleep(BaseSettings.click_time_wait)
        create_ssh_key(self.driver, Settings.user_full_name, Settings.key_name)
        _search(self.driver, Settings.key_name)
        print 'Find key in list'
        xpath = '//span[contains(text(), "%s")]' % Settings.key_name
        assert element_exists(self.driver, xpath=xpath), 'Error: Key with name "%s" is not found' % Settings.key_name
        self.ssh_key_exists = True
        print 'SSH key exists: ', self.ssh_key_exists
        print 'SSH key was created successfully'

        # Blocker SAAS-1141
        # Create resource
        print 'Resource is going to be created.'
        create_resource_openstack(self.driver, Settings.project_name, Settings.resource_name, Settings.category_name,
                                  Settings.provider_name_in_resource, Settings.image_name, Settings.flavor_name,
                                  Settings.public_key_name)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.resource_name
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot create resource "%s"' % Settings.resource_name
        self.resource_exists = True
        print 'Resource exists: ', self.resource_exists
        print 'Find online state of created resource'
        try:
            WebDriverWait(self.driver, Settings.time_wait_for_resource_creation).until(
                EC.presence_of_element_located((By.XPATH, '//div[contains(text(), "Online")]')))
        except TimeoutException as e:
            print 'Error: Resource is not online'
            raise e
        else:
            print 'Resource is in online state'
        print 'Resource was created successfully.'

        # Delete resource
        print 'Resource is going to be deleted.'
        delete_resource(self.driver, Settings.resource_name, Settings.project_name,
                        Settings.time_wait_after_resource_stopping)
        self.resource_exists = False
        print 'Resource exists: ', self.resource_exists
예제 #15
0
    def test_add_remove_resource(self):
        # Login NC
        print '%s is going to be logged in.' % Settings.username
        login_nodeconductor(self.driver, Settings.username, Settings.password)
        username_idt_field = self.driver.find_element_by_class_name(
            'user-name')
        assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.'
        print '%s was logged in successfully.' % Settings.username

        # Choose organization
        print 'Organization is going to be chosen.'
        choose_organization(self.driver, Settings.organization)
        print 'Organization was chosen successfully.'

        # Add project
        print 'Project is going to be added.'
        add_project(self.driver, self.project_name)
        time.sleep(BaseSettings.click_time_wait)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % self.project_name
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot add project "%s"' % self.project_name
        self.project_exists = True
        print 'Project exists: ', self.project_exists
        print 'Project was added successfully.'

        # Add ssh key
        print 'SSH key is going to be added.'
        time.sleep(BaseSettings.click_time_wait)
        add_ssh_key(self.driver, Settings.user_full_name, self.key_name)
        _search(self.driver, self.key_name)
        print 'Find key in list'
        xpath = '//span[contains(text(), "%s")]' % self.key_name
        assert element_exists(
            self.driver, xpath=xpath
        ), 'Error: Key with name "%s" is not found' % self.key_name
        self.ssh_key_exists = True
        print 'SSH key exists: ', self.ssh_key_exists
        print 'SSH key was added successfully'

        # Blocker SAAS-1207
        # Add resource
        print 'Resource is going to be added.'
        add_resource_openstack(self.driver, self.project_name,
                               self.resource_name, Settings.category_name,
                               Settings.provider_name_in_resource,
                               Settings.image_name, Settings.flavor_name,
                               Settings.public_key_name)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % self.resource_name
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot add resource "%s"' % self.resource_name
        self.resource_exists = True
        print 'Resource exists: ', self.resource_exists
        print 'Find online state of added resource'
        try:
            WebDriverWait(self.driver,
                          Settings.time_wait_for_resource_creation).until(
                              EC.presence_of_element_located(
                                  (By.XPATH,
                                   '//div[contains(text(), "Online")]')))
        except TimeoutException as e:
            print 'Error: Resource is not online'
            raise e
        else:
            print 'Resource is in online state'
        print 'Resource was added successfully.'

        # Blocker SAAS-1209
        # Remove resource
        print 'Resource is going to be removed.'
        remove_resource(self.driver, self.resource_name, self.project_name,
                        Settings.time_wait_after_resource_stopping)
        self.resource_exists = False
        print 'Resource exists: ', self.resource_exists
        _search(self.driver, self.resource_name)
        print 'Wait till resource will be removed'
        try:
            WebDriverWait(self.driver,
                          Settings.time_wait_after_resource_removal).until(
                              EC.invisibility_of_element_located(
                                  (By.XPATH, '//a[contains(text(), "%s")]' %
                                   self.resource_name)))
        except TimeoutException as e:
            print 'Error: Resource with name "%s" was not removed, it still exists' % self.resource_name
            raise e
        print 'Resource was removed successfully.'
    def tearDown(self):
        print '\n\n\n --- TEARDOWN ---'
        if sys.exc_info()[0] is not None:
            make_screenshot(self.driver)
        if self.application_project_exists:
            try:
                # Delete application project
                print 'Application project is going to be deleted.'
                delete_application_project(self.driver, Settings.project_name, Settings.application_project_name)
                self.application_project_exists = False
                print 'Application project exists: ', self.application_project_exists
                _search(self.driver, Settings.application_project_name)
                print 'Wait till application project will be deleted'
                try:
                    WebDriverWait(self.driver, Settings.time_wait_to_delete_application).until(
                        EC.invisibility_of_element_located((By.XPATH, '//a[contains(text(), "%s")]' % Settings.application_project_name)))
                except TimeoutException as e:
                    print 'Error: Application project with name "%s" was not deleted, it still exists' % Settings.application_project_name
                    raise e
                else:
                    print 'Application project was deleted successfully.'
            except Exception as e:
                print 'Application project cannot be deleted. Error: %s' % e

        if self.application_group_exists:
            try:
                # Delete application group
                print 'Application group is going to be deleted.'
                delete_application_group(self.driver, Settings.project_name, Settings.application_group_name)
                self.application_group_exists = False
                print 'Application group exists: ', self.application_group_exists
                _search(self.driver, Settings.application_group_name)
                print 'Wait till application group will be deleted'
                try:
                    WebDriverWait(self.driver, Settings.time_wait_to_delete_application).until(
                        EC.invisibility_of_element_located((By.XPATH, '//a[contains(text(), "%s")]' % Settings.application_group_name)))
                except TimeoutException as e:
                    print 'Error: Application group with name "%s" was not deleted, it still exists' % Settings.application_group_name
                    raise e
                else:
                    print 'Application group was deleted successfully.'
            except Exception as e:
                print 'Application group cannot be deleted. Error: %s' % e

        if self.project_exists:
            try:
                # Delete project
                print 'Project is going to be deleted.'
                delete_project(self.driver, Settings.project_name)
                self.project_exists = False
                print 'Project exists: ', self.project_exists
                time.sleep(BaseSettings.click_time_wait)
                _search(self.driver, Settings.project_name)
                if element_exists(self.driver, xpath='//a[contains(text(), "%s")]' % Settings.project_name):
                    self.project_exists = True
                print 'Project was deleted successfully.'
            except Exception as e:
                print 'Project cannot be deleted. Error: "%s"' % e

        if self.application_project_exists:
            print 'Warning! Test cannot delete application project %s. It has to be deleted manually.' % Settings.application_project_name
        if self.application_group_exists:
            print 'Warning! Test cannot delete application group %s. It has to be deleted manually.' % Settings.application_group_name
        if self.project_exists:
            print 'Warning! Test cannot delete project %s. It has to be deleted manually.' % Settings.project_name

        self.driver.quit()
    def test_create_delete_project_provider_resource(self):
        # Login NC
        print '%s is going to be logged in.' % Settings.username
        login_nodeconductor(self.driver, Settings.username, Settings.password)
        username_idt_field = self.driver.find_element_by_class_name(
            'user-name')
        assert username_idt_field.text == Settings.user_full_name, 'Error. Another username.'
        print '%s was logged in successfully.' % Settings.username

        # Choose organization
        print 'Organization is going to be chosen.'
        choose_organization(self.driver, Settings.organization)
        print 'Organization was chosen successfully.'

        # Create project
        print 'Project is going to be created.'
        create_project(self.driver, Settings.project_name)
        time.sleep(BaseSettings.click_time_wait)
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.project_name
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot create project "%s"' % Settings.project_name
        self.project_exists = True
        print 'Project was created successfully.'

        # Create provider
        print 'Provider is going to be created.'
        create_provider_digitalocean(self.driver, Settings.provider_name,
                                     Settings.provider_type_name,
                                     Settings.digitalocean_access_token)
        print 'Search created provider'
        search_field = self.driver.find_element_by_css_selector(
            '[ng-model="generalSearch"]')
        search_field.clear()
        search_field.send_keys(Settings.provider_name)
        time.sleep(BaseSettings.search_time_wait)
        print 'Find provider in list'
        xpath = '//span[contains(text(), "%s")]' % Settings.provider_name
        assert element_exists(
            self.driver, xpath=xpath
        ), 'Error: Provider with name "%s" is not found' % Settings.provider_name
        self.provider_exists = True
        print 'Find online state of created provider'
        try:
            WebDriverWait(self.driver, 30).until(
                EC.presence_of_element_located(
                    (By.CSS_SELECTOR, ".status-circle.online")))
        except TimeoutException as e:
            print 'Error: Provider is not online'
            raise e
        else:
            print 'Provider is in online status'
        print 'Provider was created successfully.'

        # Import resource
        print 'Resource is going to be imported.'
        import_resource(self.driver, Settings.project_name,
                        Settings.provider_name, Settings.category_name,
                        Settings.resource_name)
        print 'Search imported resource'
        search_field = self.driver.find_element_by_css_selector(
            '[ng-model="generalSearch"]')
        search_field.clear()
        search_field.send_keys(Settings.resource_name)
        time.sleep(BaseSettings.search_time_wait)
        print 'Go to resource page'
        resource = self.driver.find_element_by_link_text(
            Settings.resource_name)
        resource.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Check imported resource existence'
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.resource_name
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot import resource "%s"' % Settings.resource_name
        self.resource_exists = True
        print 'Resource exists: ', self.resource_exists
        print 'Check imported resource state'
        xpath = '//dd[contains(text(), "Online")]'
        assert bool(
            self.driver.find_elements_by_xpath(xpath)
        ), 'Error: Imported resource "%s" is not online.' % Settings.resource_name
        print 'Imported resource is in online state'
        print 'Resource was imported successfully.'

        print '----- Cost is going to be checked----- '
        go_to_main_page(self.driver)
        costs = self.driver.find_element_by_link_text('Costs')
        costs.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Select resources tab'
        resources_list = self.driver.find_element_by_css_selector(
            '[ng-class="{\'active\': row.selected && row.activeTab==\'resources\'}"]'
        )
        resources_list.click()
        time.sleep(BaseSettings.click_time_wait)
        print 'Find row with the resource in a resource table'
        rows_list = self.driver.find_elements_by_css_selector(
            '[ng-repeat="resource in row.resources"]')
        resource_cost_exists = False
        for row in rows_list:
            if Settings.resource_name in row.text:
                assert Settings.resource_cost in row.text, 'Error: Cannot find resource cost "%s" to check cost' % Settings.resource_cost
                resource_cost_exists = True
                print 'Resource cost "%s" was found on page' % Settings.resource_cost
        assert resource_cost_exists, 'Error: Cannot find resource with name "%s" ' % Settings.resource_name
        time.sleep(BaseSettings.click_time_wait)
        print '----- Cost was checked successfully----- '

        # Unlink resource
        print 'Resource is going to be unlinked.'
        unlink_resource(self.driver, Settings.project_name,
                        Settings.resource_name)
        print 'Search imported resource'
        search_field = self.driver.find_element_by_css_selector(
            '[ng-model="generalSearch"]')
        search_field.clear()
        search_field.send_keys(Settings.resource_name)
        time.sleep(BaseSettings.search_time_wait)
        print 'Check unlinked resource existence'
        assert not element_exists(
            self.driver,
            xpath='//a[contains(text(), "%s")]' % Settings.resource_name
        ), ('Error: Resource with name "%s" was not unlinked, it still exists'
            % Settings.resource_name)
        self.resource_exists = False
        print 'Resource exists: ', self.resource_exists
        print 'Resource was unlinked successfully.'