当前位置: 首页>>代码示例>>Python>>正文


Python version.pick函数代码示例

本文整理汇总了Python中utils.version.pick函数的典型用法代码示例。如果您正苦于以下问题:Python pick函数的具体用法?Python pick怎么用?Python pick使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pick函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: exists

def exists(root, sub=None, and_is_not_greyed=False):
    """ Checks presence and usability of toolbar buttons.

    By default it checks whether the button is available, not caring whether it is greyed or not.
    You can optionally enable check for greyedness.

    Args:
        root: Button name.
        sub: Item name (optional)
        and_is_not_greyed: Check if the button is available to click.

    """
    sel.wait_for_ajax()
    if isinstance(root, dict):
        root = version.pick(root)
    if isinstance(sub, dict):
        sub = version.pick(sub)

    try:
        greyed = is_greyed(root, sub)
        if and_is_not_greyed:
            return not greyed
        else:
            return True
    except sel.NoSuchElementException:
        return False
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:26,代码来源:toolbar.py

示例2: test_vm_retire_extend

def test_vm_retire_extend(request, testing_vm, soft_assert, retire_extend_button):
    """ Tests extending a retirement using an AE method.

    Prerequisities:
        * A running VM on any provider.

    Steps:
        * It creates a button pointing to ``Request/vm_retire_extend`` instance. The button should
            live in the VM and Instance button group.
        * Then it sets a retirement date for the VM
        * Then it waits until the retirement date is set
        * Then it clicks the button that was created and it waits for the retirement date to extend.

    Metadata:
        test_flag: retire, provision
    """
    num_days = 5
    soft_assert(testing_vm.retirement_date == 'Never', "The retirement date is not 'Never'!")
    retirement_date = generate_retirement_date(delta=num_days)
    testing_vm.set_retirement_date(retirement_date)
    wait_for(lambda: testing_vm.retirement_date != 'Never', message="retirement date set")
    set_date = testing_vm.retirement_date
    if not BZ(1419150, forced_streams='5.6').blocks:
        soft_assert(set_date == retirement_date.strftime(pick(VM.RETIRE_DATE_FMT)),
                    "The retirement date '{}' did not match expected date '{}'"
                    .format(set_date, retirement_date.strftime(pick(VM.RETIRE_DATE_FMT))))
    # current_retirement_date = testing_vm.retirement_date

    # Now run the extend stuff
    retire_extend_button()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:30,代码来源:test_common_methods.py

示例3: delete

    def delete(self, from_dest='All'):
        """
        Delete the catalog, starting from the destination provided by from_dest
        Throws cfme.DestinationNotFound exception

        :param from_dest: A valid navigation destination to start the delete from
        :return: none
        """
        if from_dest in navigator.list_destinations(self):
            navigate_to(self, from_dest)
        else:
            msg = 'cfme.services.catalogs.catalog does not have destination {}'.format(from_dest)
            raise DestinationNotFound(msg)

        # Delete using the appropriate method
        if from_dest == 'All':
            # Select the row to delete, assuming default List View for All
            listview_table.select_row_by_cells({'Name': self.name, 'Description': self.description})
            cfg_btn(version.pick({version.LOWEST: 'Remove Items from the VMDB',
                    '5.7': 'Remove Catalog Items'}), invokes_alert=True)
        elif from_dest == 'Details':
            cfg_btn(version.pick({version.LOWEST: 'Remove Item from the VMDB',
                    '5.7': 'Remove Catalog'}), invokes_alert=True)

        sel.handle_alert()
        flash.assert_success_message(
            'Catalog "{}": Delete successful'.format(self.description or self.name))
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:27,代码来源:catalog.py

示例4: delete

    def delete(self, cancel=False, wait_deleted=True, force=False):
        """Deletes the manager through UI

        Args:
            cancel (bool): Whether to cancel out of the deletion, when the alert pops up.
            wait_deleted (bool): Whether we want to wait for the manager to disappear from the UI.
                True will wait; False will only delete it and move on.
            force (bool): Whether to try to delete the manager even though it doesn't exist.
                True will try to delete it anyway; False will check for its existence and leave,
                if not present.
        """
        if not force and not self.exists:
            return
        navigate_to(self, 'All')
        sel.check(Quadicon(self.quad_name, None).checkbox())
        item_text = version.pick({'5.6': 'Remove selected items from the VMDB',
                                  '5.7': 'Remove selected items'})
        cfg_btn(item_text, invokes_alert=True)

        sel.handle_alert(cancel)
        if not cancel:
            flash_msg = version.pick({'5.6': 'Delete initiated for 1 provider',
                                      '5.7': 'Delete initiated for 1 Provider'})

            flash.assert_message_match(flash_msg)
            if wait_deleted:
                wait_for(func=lambda: self.exists, fail_condition=True, delay=15, num_sec=60)
开发者ID:rananda,项目名称:cfme_tests,代码行数:27,代码来源:config_management.py

示例5: verify_retirement_date

def verify_retirement_date(test_vm, expected_date='Never'):
    """Verify the retirement date for a variety of situations

    Args:
        expected_date: a :py:class: `str` or :py:class: `parsetime` date
            or a dict of :py:class: `parsetime` dates with 'start' and 'end' keys.
    """
    if isinstance(expected_date, dict):
        # convert to a parsetime object for comparsion, function depends on version
        if 'UTC' in pick(VM.RETIRE_DATE_FMT):
            convert_func = parsetime.from_american_minutes_with_utc
        else:
            convert_func = parsetime.from_american_date_only
        expected_date.update({'retire': convert_func(test_vm.retirement_date)})
        logger.info('Asserting retire date "%s" is between "%s" and "%s"',  # noqa
                    expected_date['retire'],
                    expected_date['start'],
                    expected_date['end'])

        assert expected_date['start'] <= expected_date['retire'] <= expected_date['end']

    elif isinstance(expected_date, (parsetime, datetime, date)):
        assert test_vm.retirement_date == expected_date.strftime(pick(VM.RETIRE_DATE_FMT))
    else:
        assert test_vm.retirement_date == expected_date
开发者ID:rananda,项目名称:cfme_tests,代码行数:25,代码来源:test_retirement.py

示例6: report_vms

def report_vms(setup_first_provider):
    report = CustomReport(
        menu_name=generate_random_string(),
        title=generate_random_string(),
        base_report_on="Virtual Machines",
        report_fields=[
            version.pick({
                version.LOWEST: "Provider : Name",
                "5.3": "Cloud/Infrastructure Provider : Name",
            }),
            "Cluster : Name",
            "Datastore : Name",
            "Hardware : Number of CPUs",
            "Hardware : RAM",
            "Host : Name",
            "Name",
        ]
    )
    report.create()
    report.queue(wait_for_finish=True)
    yield pick(
        filter(
            lambda i: len(i[
                version.pick({
                    version.LOWEST: "Provider : Name",
                    "5.3": "Cloud/Infrastructure Provider Name",
                })
            ].strip()) > 0,
            list(report.get_saved_reports()[0].data.rows)), 2)
    report.delete()
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:30,代码来源:test_report_corresponds.py

示例7: nav_edit

 def nav_edit(self):
     dp_length = version.pick({version.LOWEST: 1,
                               '5.3': 2})
     if len(self.nav_path) > dp_length:
         cfg_btn('Edit Selected Item')
     else:
         cfg_btn(version.pick({version.LOWEST: 'Edit Selected Namespaces',
                               '5.3': 'Edit Selected Namespace'}))
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:8,代码来源:explorer.py

示例8: view_value_mapping

 def view_value_mapping(self):
     return {'hostname': self.hostname,
             'api_port': getattr(self, 'api_port', None),
             'verify_tls': version.pick({version.LOWEST: None,
                                         '5.8': getattr(self, 'verify_tls', None)}),
             'ca_certs': version.pick({version.LOWEST: None,
                                       '5.8': getattr(self, 'ca_certs', None)})
             }
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:8,代码来源:rhevm.py

示例9: old_select

def old_select(root, sub=None, invokes_alert=False):
    """ Clicks on a button by calling the dhtmlx toolbar callEvent.

    Args:
        root: The root button's name as a string.
        sub: The sub button's name as a string. (optional)
        invokes_alert: If ``True``, then the behaviour is little bit different. After the last
            click, no ajax wait and no move away is done to be able to operate the alert that
            appears after click afterwards. Defaults to ``False``.
    Returns: ``True`` if everything went smoothly
    Raises: :py:class:`cfme.exceptions.ToolbarOptionGreyedOrUnavailable`
    """
    # wait for ajax on select to prevent pickup up a toolbar button in the middle of a page change
    sel.wait_for_ajax()
    if isinstance(root, dict):
        root = version.pick(root)
    if sub is not None and isinstance(sub, dict):
        sub = version.pick(sub)

    root_obj = version.pick({'5.4': 'miq_toolbars',
        '5.5.0.7': 'ManageIQ.toolbars'})

    if sub:
        search = sub_loc(sub)
    else:
        search = root_loc(root)

    eles = sel.elements(search)

    for ele in eles:
        idd = sel.get_attribute(ele, 'idd')
        if idd:
            break
    else:
        raise ToolbarOptionGreyedOrUnavailable(
            "Toolbar button {}/{} is greyed or unavailable!".format(root, sub))

    buttons = sel.execute_script('return {}'.format(root_obj))
    tb_name = None
    for tb_key, tb_obj in buttons.iteritems():
        for btn_key, btn_obj in tb_obj['buttons'].iteritems():
            if btn_obj['name'] == idd:
                tb_name = tb_key
    if not tb_name:
        raise ToolbarOptionGreyedOrUnavailable(
            "Toolbar button {}/{} is greyed or unavailable!".format(root, sub))

    sel.execute_script(
        "{}['{}']['obj'].callEvent('onClick', ['{}'])".format(root_obj, tb_name, idd))

    if not invokes_alert:
        sel.wait_for_ajax()
    return True
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:53,代码来源:toolbar.py

示例10: __init__

 def __init__(
         self, name=None, credentials=None, key=None, zone=None, provider_data=None):
     if not credentials:
         credentials = {}
     self.name = name
     self.credentials = credentials
     self.key = key
     self.provider_data = provider_data
     self.zone = zone
     self.vm_name = version.pick({version.LOWEST: "VMs", '5.5': "VMs and Instances"})
     self.template_name = version.pick(
         {version.LOWEST: "Templates", '5.5': "VM Templates and Images"})
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:12,代码来源:provider.py

示例11: __getattr__

    def __getattr__(self, attr):
        """Resulve the button clicking action."""
        try:
            a_tuple = self.buttons[attr]
        except KeyError:
            raise AttributeError("Action {} does not exist".format(attr))
        action = version.pick(dict(zip(self.versions, self.actions)))
        action_meth = getattr(self, action)
        action_data = version.pick(dict(zip(self.versions, a_tuple)))

        def _click_function():
            action_meth(action_data)

        return _click_function
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:14,代码来源:ui_elements.py

示例12: delete

 def delete(self, cancel=False):
     sel.force_navigate("automate_explorer_table_select", context={'tree_item': self.parent,
                                                                   'table_item': self})
     dp_length = version.pick({version.LOWEST: 1,
                               '5.3': 2})
     if len(self.path) > dp_length:
         cfg_btn('Remove selected Items', invokes_alert=True)
     else:
         cfg_btn('Remove Namespaces', invokes_alert=True)
     sel.handle_alert(cancel)
     del_msg = version.pick({
         version.LOWEST: 'The selected Automate Namespaces were deleted',
         '5.3': 'Automate Namespace "{}": Delete successful'.format(self.description)
     })
     flash.assert_success_message(del_msg)
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:15,代码来源:explorer.py

示例13: test_permission_edit

def test_permission_edit(request, product_features, action):
    """
    Ensures that changes in permissions are enforced on next login
    """
    product_features = version.pick(product_features)
    request.addfinalizer(login.login_admin)
    role_name = fauxfactory.gen_alphanumeric()
    role = ac.Role(
        name=role_name,
        vm_restriction=None,
        product_features=[(["Everything"], False)] + [(k, True) for k in product_features],  # role_features
    )
    role.create()
    group = new_group(role=role.name)
    group.create()
    user = new_user(group=group)
    user.create()
    with user:
        try:
            action()
        except Exception:
            pytest.fail("Incorrect permissions set")
    login.login_admin()
    role.update({"product_features": [(["Everything"], True)] + [(k, False) for k in product_features]})
    with user:
        try:
            with error.expected(Exception):
                action()
        except error.UnexpectedSuccessException:
            pytest.Fails("Permissions have not been updated")
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:30,代码来源:test_access_control.py

示例14: _provisioner

    def _provisioner(template, provisioning_data, delayed=None):
        pytest.sel.force_navigate('infrastructure_provision_vms', context={
            'provider': provider,
            'template_name': template,
        })

        vm_name = provisioning_data["vm_name"]
        fill(provisioning_form, provisioning_data, action=provisioning_form.submit_button)
        flash.assert_no_errors()

        request.addfinalizer(lambda: cleanup_vm(vm_name, provider))
        if delayed is not None:
            total_seconds = (delayed - datetime.utcnow()).total_seconds()
            row_description = 'Provision from [%s] to [%s]' % (template, vm_name)
            cells = {'Description': row_description}
            try:
                row, __ = wait_for(requests.wait_for_request, [cells],
                                   fail_func=requests.reload, num_sec=total_seconds, delay=5)
                pytest.fail("The provisioning was not postponed")
            except TimedOutError:
                pass
        logger.info('Waiting for vm %s to appear on provider %s', vm_name, provider.key)
        wait_for(provider.mgmt.does_vm_exist, [vm_name], handle_exception=True, num_sec=600)

        # nav to requests page happens on successful provision
        logger.info('Waiting for cfme provision request for vm %s' % vm_name)
        row_description = 'Provision from [%s] to [%s]' % (template, vm_name)
        cells = {'Description': row_description}
        row, __ = wait_for(requests.wait_for_request, [cells],
                           fail_func=requests.reload, num_sec=900, delay=20)
        assert row.last_message.text == version.pick(
            {version.LOWEST: 'VM Provisioned Successfully',
             "5.3": 'Vm Provisioned Successfully', })
        return VM.factory(vm_name, provider)
开发者ID:vrutkovs,项目名称:cfme_tests,代码行数:34,代码来源:test_provisioning_dialog.py

示例15: default

 def default(cls):
     if not hasattr(cls, "_default_domain"):
         cls._default_domain = version.pick({
             version.LOWEST: None,
             '5.3': cls('Default')
         })
     return cls._default_domain
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:7,代码来源:explorer.py


注:本文中的utils.version.pick函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。