Beispiel #1
0
    def test_organization_balance(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

        # Add organization
        print 'Organization is going to be added.'
        time.sleep(BaseSettings.click_time_wait)
        add_organization(self.driver, self.organization)
        print 'Existence check of added organization'
        xpath = '//span[@class="name" and contains(text(), "%s")]' % self.organization
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot add organization "%s"' % self.organization
        self.organization_exists = True
        print 'Organization exists: ', self.organization_exists
        print 'Organization was added successfully.'

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

        # Top-up balance
        print 'Balance is going to be topped-up.'
        print 'Check "$0.00" balance'
        xpath = '//div[contains(text(), "%s")]' % Settings.balance
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot find balance "%s"' % Settings.balance
        print 'Top-up balance'
        top_up_organization_balance(self.driver, Settings.top_up_balance,
                                    Settings.payment_account_email,
                                    Settings.payment_account_password,
                                    Settings.time_wait_alert_is_present,
                                    Settings.time_wait_alert_invisibility,
                                    Settings.time_wait_to_swich_to_paypal)
        print 'Wait till balance will be topped-up'
        WebDriverWait(self.driver, Settings.time_wait_to_topup_balance).until(
            EC.invisibility_of_element_located((
                By.XPATH,
                '//div[contains(text(), "Payment is being proceeded, please wait")]'
            )))
        print 'Check topped-up balance'
        xpath = '//div[contains(text(), "%s")]' % Settings.check_balance
        assert bool(self.driver.find_elements_by_xpath(
            xpath)), 'Cannot find balance "%s"' % Settings.check_balance
        print 'Balance was topped-up successfully.'
    def test_organization_balance(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

        # Add organization
        print 'Organization is going to be added.'
        time.sleep(BaseSettings.click_time_wait)
        add_organization(self.driver, self.organization)
        print 'Existence check of added organization'
        xpath = '//span[@class="name" and contains(text(), "%s")]' % self.organization
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot add organization "%s"' % self.organization
        self.organization_exists = True
        print 'Organization exists: ', self.organization_exists
        print 'Organization was added successfully.'

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

        # Top-up balance
        print 'Balance is going to be topped-up.'
        print 'Check "$0.00" balance'
        xpath = '//div[contains(text(), "%s")]' % Settings.balance
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot find balance "%s"' % Settings.balance
        print 'Top-up balance'
        top_up_organization_balance(self.driver, Settings.top_up_balance, Settings.payment_account_email,
                                    Settings.payment_account_password, Settings.time_wait_alert_is_present,
                                    Settings.time_wait_alert_invisibility, Settings.time_wait_to_swich_to_paypal)
        print 'Wait till balance will be topped-up'
        WebDriverWait(self.driver, Settings.time_wait_to_topup_balance).until(
            EC.invisibility_of_element_located((By.XPATH, '//div[contains(text(), "Payment is being proceeded, please wait")]')))
        print 'Check topped-up balance'
        xpath = '//div[contains(text(), "%s")]' % Settings.check_balance
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot find balance "%s"' % Settings.check_balance
        print 'Balance was topped-up successfully.'
    def test_organization_balance(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

        # Create organization
        print 'Organization is going to be created.'
        time.sleep(BaseSettings.click_time_wait)
        create_organization(self.driver, Settings.organization)
        print 'Existence check of created organization'
        xpath = '//span[@class="name" and contains(text(), "%s")]' % Settings.organization
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot create organization "%s"' % Settings.organization
        self.organization_exists = True
        print 'Organization exists: ', self.organization_exists
        print 'Organization was created successfully.'

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

        # Top-up balance
        print 'Balance is going to be topped-up.'
        print 'Check "$0.00" balance'
        xpath = '//div[contains(text(), "%s")]' % Settings.balance
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot find balance "%s"' % Settings.balance
        print 'Top-up balance'
        top_up_organization_balance(self.driver, Settings.top_up_balance, Settings.payment_account_email, Settings.payment_account_password)
        time.sleep(BaseSettings.click_time_wait)
        print 'Check topped-up balance'
        xpath = '//div[contains(text(), "%s")]' % Settings.check_balance
        assert bool(self.driver.find_elements_by_xpath(xpath)), 'Cannot find balance "%s"' % Settings.check_balance
        print 'Balance was topped-up successfully.'
    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.'
    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.'