예제 #1
0
def _fill_assignform_dict(form, d):
    d = copy(d)  # Mutable
    for name, value in d.iteritems():
        if value is None:
            value = "<Nothing>"
        select = form.select_by_name(name)
        sel.select(select, value)
예제 #2
0
def _fill_assignform_dict(form, d):
    d = copy(d)  # Mutable
    for name, value in d.iteritems():
        if value is None:
            value = "<Nothing>"
        select = form.select_by_name(name)
        sel.select(select, value)
예제 #3
0
    def mapping(self):
        """Determine mapping Menu item => menu item id.

        Needed because the boxes with shortcuts are accessible only via ids.
        Need to close boxes because boxes displayed are not in the Select.
        """
        # Save opened boxes
        closed_boxes = []
        for box_id in self.opened_boxes_ids:
            closed_boxes.append((self.get_text_of(box_id), box_id))
            self.close_box(box_id)
        # Check the select
        result = {}
        for option in self.select.options:
            try:
                result[sel.text(option)] = int(
                    sel.get_attribute(option, "value"))
            except (ValueError, TypeError):
                pass
        # Restore box layout
        for name, id in closed_boxes:
            sel.select(self.select, sel.ByValue(str(id)))
            self.set_text_of(id, name)

        return result
예제 #4
0
    def _select_selected(self, *items):
        """ Selects items in 'Selected items' list

        Args:
            *items: Items to select
        """
        for item in items:
            sel.select(self._selected, item)
예제 #5
0
def sort_by(sort):
    """ Changes the sort by field.

    Args:
        sort: Value to sort by (visible text in select box)
    """
    select = sel.element(_locator + _sort_by)
    sel.select(Select(select), sel.ByText(sort))
예제 #6
0
def results_per_page(num):
    """ Changes the number of results on a page.

    Args:
        num: Number of results per page
    """
    select = sel.element(_locator + _num_results)
    sel.select(Select(select), sel.ByText(str(num)))
예제 #7
0
    def _select_selected(self, *items):
        """ Selects items in 'Selected items' list

        Args:
            *items: Items to select
        """
        for item in items:
            sel.select(self._selected, item)
예제 #8
0
def results_per_page(num):
    """ Changes the number of results on a page.

    Args:
        num: Number of results per page
    """
    select = sel.element(_locator + _num_results)
    sel.select(Select(select), sel.ByText(str(num)))
예제 #9
0
def sort_by(sort):
    """ Changes the sort by field.

    Args:
        sort: Value to sort by (visible text in select box)
    """
    select = sel.element(_locator + _sort_by)
    sel.select(Select(select), sel.ByText(sort))
예제 #10
0
    def create(self):
        # Create has sequential forms, the first is only the provider type
        navigate_to(self, 'Add')
        # For element not found exception (To be removed)
        sel.sleep(5)
        sel.select("//select[@id='st_prov_type']",
                   self.provider_type or self.item_type or 'Generic')

        sel.wait_for_element(basic_info_form.name_text)
        catalog = fakeobject_or_object(self.catalog, "name", "Unassigned")
        dialog = fakeobject_or_object(self.dialog, "name", "No Dialog")

        # Need to provide the (optional) provider name to the form, not the object
        provider_name = None
        provider_required_types = ['AnsibleTower', 'Orchestration']
        if self.item_type in provider_required_types \
                or self.provider_type in provider_required_types:
            provider_name = self.provider.name
        # For tests where orchestration template is None
        orch_template = None
        if self.orch_template:
            orch_template = self.orch_template.template_name

        fill(basic_info_form, {'name_text': self.name,
                               'description_text': self.description,
                               'display_checkbox': self.display_in,
                               'select_catalog': catalog.name,
                               'select_dialog': dialog.name,
                               'select_orch_template': orch_template,
                               'select_provider': provider_name,
                               'select_config_template': self.config_template})
        if not (self.item_type in provider_required_types):
            sel.click(basic_info_form.field_entry_point)
            if version.current_version() < "5.7":
                dynamic_tree.click_path("Datastore", self.domain, "Service", "Provisioning",
                                     "StateMachines", "ServiceProvision_Template", "default")
            else:
                entry_tree.click_path("Datastore", self.domain, "Service", "Provisioning",
                    "StateMachines", "ServiceProvision_Template", "default")
            sel.click(basic_info_form.apply_btn)
        if version.current_version() >= "5.7" and self.item_type == "AnsibleTower":
            sel.click(basic_info_form.retirement_entry_point)
            entry_tree.click_path("Datastore", self.domain, "Service", "Retirement",
                    "StateMachines", "ServiceRetirement", "Generic")
            sel.click(basic_info_form.apply_btn)
        if self.catalog_name is not None \
                and self.provisioning_data is not None \
                and not isinstance(self.provider, NoneType):
            tabstrip.select_tab("Request Info")
            tabstrip.select_tab("Catalog")
            template = template_select_form.template_table.find_row_by_cells({
                'Name': self.catalog_name,
                'Provider': self.provider.name
            })
            sel.click(template)
            request_form.fill(self.provisioning_data)
        sel.click(template_select_form.add_button)
예제 #11
0
def sort_by(sort):
    """ Changes the sort by field.

    Args:
        sort: Value to sort by (visible text in select box)
    """
    _select = version.pick({
        version.LOWEST: Select(_locator() + _sort_by),
        "5.5": AngularSelect('sort_choice')})
    sel.select(_select, sel.ByText(str(sort)))
예제 #12
0
def results_per_page(num):
    """ Changes the number of results on a page.

    Args:
        num: Number of results per page
    """
    _select = version.pick({
        version.LOWEST: Select(_locator + _num_results),
        "5.5": AngularSelect('ppsetting')})
    sel.select(_select, sel.ByText(str(num)))
예제 #13
0
def sort_by(sort):
    """ Changes the sort by field.

    Args:
        sort: Value to sort by (visible text in select box)
    """
    _select = version.pick({
        version.LOWEST: Select(_locator + _sort_by),
        "5.5": AngularSelect('sort_choice')})
    sel.select(_select, sel.ByText(str(sort)))
예제 #14
0
def results_per_page(num):
    """ Changes the number of results on a page.

    Args:
        num: Number of results per page
    """
    _select = version.pick({
        version.LOWEST: Select(_locator() + _num_results),
        "5.5": AngularSelect('ppsetting')})
    sel.select(_select, sel.ByText(str(num)))
예제 #15
0
    def add(self, menu, alias=None):
        """Add a new shortcut.

        Args:
            menu: What menu item to select.
            alias: Optional alias for this menu item.
        """
        if menu not in self.mapping:
            raise NameError("Unknown menu location {}!".format(menu))
        sel.select(self.select, sel.ByValue(str(self.mapping[menu])))
        if alias is not None:
            self.set_text_of(self.mapping[menu], alias)
예제 #16
0
def sort_by(sort):
    """ Changes the sort by field.

    Args:
        sort: Value to sort by (visible text in select box)
    """
    if version.current_version() > '5.5.0.7':
        select = AngularSelect('sort_choice')
        sel.select(select, sel.ByText(str(sort)))
    else:
        select = sel.element(_locator + _sort_by)
        sel.select(Select(select), sel.ByText(sort))
예제 #17
0
def results_per_page(num):
    """ Changes the number of results on a page.

    Args:
        num: Number of results per page
    """
    if version.current_version() > '5.5.0.7':
        select = AngularSelect('ppsetting')
        sel.select(select, sel.ByText(str(num)))
    else:
        select = sel.element(_locator + _num_results)
        sel.select(Select(select), sel.ByText(str(num)))
예제 #18
0
    def add(self, menu, alias=None):
        """Add a new shortcut.

        Args:
            menu: What menu item to select.
            alias: Optional alias for this menu item.
        """
        if menu not in self.mapping:
            raise NameError("Unknown menu location {}!".format(menu))
        sel.select(self.select, sel.ByValue(str(self.mapping[menu])))
        if alias is not None:
            self.set_text_of(self.mapping[menu], alias)
예제 #19
0
def simulate(**data):
    """Runs the simulation of specified Automate object.

    Args:
        **data: See :py:data:`sim_form` for keyword reference
    """
    sel.force_navigate("automate_simulation")
    if data.get("attribute", None) is None:
        t = sel.text(sim_form.attribute[0].options[0]).encode("utf-8")  # None
        sel.select(sim_form.attribute[0], t)
    fill(sim_form, data, action=sim_btn)
    flash.assert_message_match("Automation Simulation has been run")
    flash.assert_no_errors()
예제 #20
0
def simulate(**data):
    """Runs the simulation of specified Automate object.

    Args:
        **data: See :py:data:`sim_form` for keyword reference
    """
    sel.force_navigate("automate_simulation")
    if data.get("attribute", None) is None:
        t = sel.text(sim_form.attribute[0].options[0]).encode("utf-8")  # None
        sel.select(sim_form.attribute[0], t)
    fill(sim_form, data, action=sim_btn)
    flash.assert_message_match("Automation Simulation has been run")
    flash.assert_no_errors()
예제 #21
0
    def create(self):
        # Create has sequential forms, the first is only the provider type
        navigate_to(self, 'Add')
        sel.select("//select[@id='st_prov_type']",
                   self.provider_type or self.item_type or 'Generic')
        sel.wait_for_element(basic_info_form.name_text)
        catalog = fakeobject_or_object(self.catalog, "name", "Unassigned")
        dialog = fakeobject_or_object(self.dialog, "name", "No Dialog")

        fill(basic_info_form, {'name_text': self.name,
                               'description_text': self.description,
                               'display_checkbox': self.display_in,
                               'select_catalog': catalog.name,
                               'select_dialog': dialog.name,
                               'select_orch_template': self.orch_template,
                               'select_provider': self.provider_type,
                               'select_config_template': self.config_template})
        if sel.text(basic_info_form.field_entry_point) == "":
            sel.click(basic_info_form.field_entry_point)
            if version.current_version() < "5.7":
                dynamic_tree.click_path("Datastore", self.domain, "Service", "Provisioning",
                                     "StateMachines", "ServiceProvision_Template", "default")
            else:
                entry_tree.click_path("Datastore", self.domain, "Service", "Provisioning",
                                     "StateMachines", "ServiceProvision_Template", "default")
            sel.click(basic_info_form.apply_btn)
        if self.catalog_name is not None and self.provisioning_data is not None:
            tabstrip.select_tab("Request Info")
            # Address BZ1321631
            tabstrip.select_tab("Environment")
            tabstrip.select_tab("Catalog")
            template = template_select_form.template_table.find_row_by_cells({
                'Name': self.catalog_name,
                # HACK to workaround BZ1390209
                # revert back to Provider once it's fixed
                'Deprecated' if BZ(1390209, forced_streams=["5.7", "upstream"]).blocks else
                'Provider': self.provider
            })
            sel.click(template)
            request_form.fill(self.provisioning_data)
        sel.click(template_select_form.add_button)
예제 #22
0
    def mapping(self):
        """Determine mapping Menu item => menu item id.

        Needed because the boxes with shortcuts are accessible only via ids.
        Need to close boxes because boxes displayed are not in the Select.
        """
        # Save opened boxes
        closed_boxes = []
        for box_id in self.opened_boxes_ids:
            closed_boxes.append((self.get_text_of(box_id), box_id))
            self.close_box(box_id)
        # Check the select
        result = {}
        for option in self.select.options:
            try:
                result[sel.text(option)] = int(sel.get_attribute(option, "value"))
            except (ValueError, TypeError):
                pass
        # Restore box layout
        for name, id in closed_boxes:
            sel.select(self.select, sel.ByValue(str(id)))
            self.set_text_of(id, name)

        return result
예제 #23
0
def _all_catalogitems_add_new(context):
    sel.click("//div[@id='sandt_tree_div']//td[.='All Catalog Items']")
    tb_select('Add a New Catalog Item')
    provider_type = context['provider_type']
    sel.select("//select[@id='st_prov_type']", provider_type)
예제 #24
0
def _all_catalogitems_add_new(context):
    accordion_tree('All Catalog Items')
    cfg_btn('Add a New Catalog Item')
    provider_type = context['provider_type']
    sel.select("//select[@id='st_prov_type']", provider_type)
예제 #25
0
 def _select_selected(self, *items):
     for item in items:
         sel.select(self._selected, item)
예제 #26
0
def update_registration(service,
                        url,
                        username,
                        password,
                        password_verify=None,
                        repo_name=None,
                        organization=None,
                        use_proxy=False,
                        proxy_url=None,
                        proxy_username=None,
                        proxy_password=None,
                        proxy_password_verify=None,
                        validate=True,
                        cancel=False,
                        set_default_rhsm_address=False,
                        set_default_repository=False):
    """ Fill in the registration form, validate and save/cancel

    Args:
        service: Service type (registration method).
        url: Service server URL address.
        username: Username to use for registration.
        password: Password to use for registration.
        password_verify: 2nd entry of password for verification.
                         Same as 'password' if None.
        repo_or_channel: Repository/channel to enable.
        organization: Organization (sat5/sat6 only).
        use_proxy: `True` if proxy should be used, `False` otherwise
                   (default `False`).
        proxy_url: Address of the proxy server.
        proxy_username: Username for the proxy server.
        proxy_password: Password for the proxy server.
        proxy_password_verify: 2nd entry of proxy server password for verification.
                               Same as 'proxy_password' if None.
        validate: Click the Validate button and check the
                  flash message for errors if `True` (default `True`)
        cancel: Click the Cancel button if `True` or the Save button
                if `False` (default `False`)
        set_default_rhsm_address: Click the Default button connected to
                                  the RHSM (only) address if `True`
        set_default_repository: Click the Default button connected to
                                the repo/channel if `True`

    Warning:
        'password_verify' and 'proxy_password_verify' are available in 5.4+ only.

    Note:
        With satellite 6, it is necessary to validate credentials to obtain
        available organizations from the server.
        With satellite 5, 'validate' parameter is ignored because there is
        no validation button available.
    """
    assert service in service_types, "Unknown service type '{}'".format(
        service)
    service_value = service_types[service]

    # In 5.4+, we have verification inputs as well
    if version.current_version() >= '5.4':
        password_verify = password_verify or password
        proxy_password_verify = proxy_password_verify or proxy_password
    # Otherwise, verification inputs are ignored df even if specified
    else:
        password_verify = None
        proxy_password_verify = None

    # Sat6 organization can be selected only after successful validation
    # while Sat5 organization is selected normally
    if service == 'sat6':
        organization_sat5 = None
        organization_sat6 = organization
    else:
        organization_sat5 = organization
        organization_sat6 = None

    sel.force_navigate("cfg_settings_region_red_hat_updates")
    sel.click(update_buttons.edit_registration)
    details = dict(service=sel.ByValue(service_value),
                   url=url,
                   username=username,
                   password=password,
                   password_verify=password_verify,
                   repo_name=repo_name,
                   organization_sat5=organization_sat5,
                   use_proxy=use_proxy,
                   proxy_url=proxy_url,
                   proxy_username=proxy_username,
                   proxy_password=proxy_password,
                   proxy_password_verify=proxy_password_verify)

    fill(registration_form, details)

    if set_default_rhsm_address:
        sel.click(registration_buttons.url_default)

    if set_default_repository:
        sel.click(registration_buttons.repo_default)

    if validate and service != 'sat5':
        sel.click(form_buttons.validate_short)
        flash.assert_no_errors()
        flash.dismiss()

    if organization_sat6:
        sel.select(registration_form.locators['organization_sat6'],
                   organization_sat6)

    if cancel:
        form_buttons.cancel()
    else:
        form_buttons.save()
        flash.assert_message_match("Customer Information successfully saved")
        flash.dismiss()
예제 #27
0
def _fill_rss_str(erf, s):
    try:
        sel.select(erf.form.rss_url, s)
    except NoSuchElementException:
        sel.select(erf.form.rss_url, "<Enter URL Manually>")
        sel.send_keys(erf.form.txt_url, s)
예제 #28
0
def _all_catalogitems_add_new(context):
    catalog_item_tree.click_path('All Catalog Items')
    tb_select('Add a New Catalog Item')
    provider_type = context['provider_type']
    sel.select("//select[@id='st_prov_type']", provider_type)
예제 #29
0
def _all_catalogitems_add_new(context):
    accordion.tree('Catalog Items', 'All Catalog Items')
    tb_select('Add a New Catalog Item')
    provider_type = context['provider_type']
    sel.select("//select[@id='st_prov_type']", provider_type)
예제 #30
0
def update_registration(service,
                        url,
                        username,
                        password,
                        password_verify=None,
                        repo_name=None,
                        organization=None,
                        use_proxy=False,
                        proxy_url=None,
                        proxy_username=None,
                        proxy_password=None,
                        proxy_password_verify=None,
                        validate=True,
                        cancel=False,
                        set_default_rhsm_address=False,
                        set_default_repository=False):
    """ Fill in the registration form, validate and save/cancel

    Args:
        service: Service type (registration method).
        url: Service server URL address.
        username: Username to use for registration.
        password: Password to use for registration.
        password_verify: 2nd entry of password for verification.
                         Same as 'password' if None.
        repo_or_channel: Repository/channel to enable.
        organization: Organization (sat5/sat6 only).
        use_proxy: `True` if proxy should be used, `False` otherwise
                   (default `False`).
        proxy_url: Address of the proxy server.
        proxy_username: Username for the proxy server.
        proxy_password: Password for the proxy server.
        proxy_password_verify: 2nd entry of proxy server password for verification.
                               Same as 'proxy_password' if None.
        validate: Click the Validate button and check the
                  flash message for errors if `True` (default `True`)
        cancel: Click the Cancel button if `True` or the Save button
                if `False` (default `False`)
        set_default_rhsm_address: Click the Default button connected to
                                  the RHSM (only) address if `True`
        set_default_repository: Click the Default button connected to
                                the repo/channel if `True`

    Warning:
        'password_verify' and 'proxy_password_verify' are available in 5.4+ only.

    Note:
        With satellite 6, it is necessary to validate credentials to obtain
        available organizations from the server.
        With satellite 5, 'validate' parameter is ignored because there is
        no validation button available.
    """
    assert service in service_types, "Unknown service type '{}'".format(service)
    service_value = service_types[service]

    # In 5.4+, we have verification inputs as well
    if version.current_version() >= '5.4':
        password_verify = password_verify or password
        proxy_password_verify = proxy_password_verify or proxy_password
    # Otherwise, verification inputs are ignored df even if specified
    else:
        password_verify = None
        proxy_password_verify = None

    # Sat6 organization can be selected only after successful validation
    # while Sat5 organization is selected normally
    if service == 'sat6':
        organization_sat5 = None
        organization_sat6 = organization
    else:
        organization_sat5 = organization
        organization_sat6 = None

    sel.force_navigate("cfg_settings_region_red_hat_updates")
    sel.click(update_buttons.edit_registration)
    details = dict(
        service=sel.ByValue(service_value),
        url=url,
        username=username,
        password=password,
        password_verify=password_verify,
        repo_name=repo_name,
        organization_sat5=organization_sat5,
        use_proxy=use_proxy,
        proxy_url=proxy_url,
        proxy_username=proxy_username,
        proxy_password=proxy_password,
        proxy_password_verify=proxy_password_verify
    )

    fill(registration_form, details)

    if set_default_rhsm_address:
        sel.click(registration_buttons.url_default)

    if set_default_repository:
        sel.click(registration_buttons.repo_default)

    if validate and service != 'sat5':
        sel.click(form_buttons.validate_short)
        flash.assert_no_errors()
        flash.dismiss()

    if organization_sat6:
        sel.select(registration_form.locators['organization_sat6'], organization_sat6)

    if cancel:
        form_buttons.cancel()
    else:
        form_buttons.save()
        flash.assert_message_match("Customer Information successfully saved")
        flash.dismiss()
예제 #31
0
def _fill_rss_str(erf, s):
    try:
        sel.select(erf.form.rss_url, s)
    except NoSuchElementException:
        sel.select(erf.form.rss_url, "<Enter URL Manually>")
        sel.send_keys(erf.form.txt_url, s)
예제 #32
0
def _all_catalogitems_add_new(context):
    catalog_item_tree.click_path('All Catalog Items')
    tb_select('Add a New Catalog Item')
    provider_type = context['provider_type']
    sel.select("//select[@id='st_prov_type']", provider_type)
예제 #33
0
def _all_catalogitems_add_new(context):
    accordion.tree("Catalog Items", "All Catalog Items")
    tb_select("Add a New Catalog Item")
    provider_type = context["provider_type"]
    sel.select("//select[@id='st_prov_type']", provider_type)