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


Python error.expected函数代码示例

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


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

示例1: test_provider_add_with_bad_credentials

def test_provider_add_with_bad_credentials(provider_crud):
    provider_crud.credentials = provider.get_credentials_from_config('bad_credentials')
    if isinstance(provider_crud, provider.VMwareProvider):
        with error.expected('Cannot complete login due to an incorrect user name or password.'):
            provider_crud.create(validate_credentials=True)
    elif isinstance(provider_crud, provider.RHEVMProvider):
        with error.expected('401 Unauthorized'):
            provider_crud.create(validate_credentials=True)
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:8,代码来源:test_providers.py

示例2: test_delete_template

def test_delete_template(rest_api, template, multiple):
    if multiple:
        rest_api.collections.templates.action.delete(template)
        with error.expected("ActiveRecord::RecordNotFound"):
            rest_api.collections.templates.action.delete(template)
    else:
        template.action.delete()
        with error.expected("ActiveRecord::RecordNotFound"):
            template.action.delete()
开发者ID:FilipB,项目名称:cfme_tests,代码行数:9,代码来源:test_rest_templates.py

示例3: test_delete_user

 def test_delete_user(self, rest_api, users, multiple):
     if multiple:
         rest_api.collections.users.action.delete(*users)
         with error.expected("ActiveRecord::RecordNotFound"):
             rest_api.collections.users.action.delete(*users)
     else:
         user = users[0]
         user.action.delete()
         with error.expected("ActiveRecord::RecordNotFound"):
             user.action.delete()
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:10,代码来源:test_rest_access_control.py

示例4: test_delete_tags

 def test_delete_tags(self, rest_api, tags, multiple):
     if multiple:
         rest_api.collections.tags.action.delete(*tags)
         with error.expected("ActiveRecord::RecordNotFound"):
             rest_api.collections.tags.action.delete(*tags)
     else:
         tag = tags[0]
         tag.action.delete()
         with error.expected("ActiveRecord::RecordNotFound"):
             tag.action.delete()
开发者ID:pavelzag,项目名称:cfme_tests,代码行数:10,代码来源:test_tag.py

示例5: test_delete_groups

 def test_delete_groups(self, rest_api, groups, multiple):
     if multiple:
         rest_api.collections.groups.action.delete(*groups)
         with error.expected("ActiveRecord::RecordNotFound"):
             rest_api.collections.groups.action.delete(*groups)
     else:
         group = groups[0]
         group.action.delete()
         with error.expected("ActiveRecord::RecordNotFound"):
             group.action.delete()
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:10,代码来源:test_rest_access_control.py

示例6: test_delete_rates

def test_delete_rates(rest_api, rates, multiple):
    if multiple:
        rest_api.collections.rates.action.delete(*rates)
        with error.expected("ActiveRecord::RecordNotFound"):
            rest_api.collections.rates.action.delete(*rates)
    else:
        rate = rates[0]
        rate.action.delete()
        with error.expected("ActiveRecord::RecordNotFound"):
            rate.action.delete()
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:10,代码来源:test_rest.py

示例7: test_delete_tenants

 def test_delete_tenants(self, rest_api, tenants, multiple):
     if multiple:
         rest_api.collections.tenants.action.delete(*tenants)
         with error.expected("ActiveRecord::RecordNotFound"):
             rest_api.collections.tenants.action.delete(*tenants)
     else:
         tenant = tenants[0]
         tenant.action.delete()
         with error.expected("ActiveRecord::RecordNotFound"):
             tenant.action.delete()
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:10,代码来源:test_rest_access_control.py

示例8: test_delete_custom_attributes

 def test_delete_custom_attributes(self, rest_api, custom_attributes, from_detail):
     """Test deleting custom attributes using REST API."""
     if from_detail:
         for ent in custom_attributes:
             ent.action.delete()
             with error.expected("ActiveRecord::RecordNotFound"):
                 ent.action.delete()
     else:
         provider = rest_api.collections.providers[0]
         provider.custom_attributes.action.delete(*custom_attributes)
         with error.expected("ActiveRecord::RecordNotFound"):
             provider.custom_attributes.action.delete(*custom_attributes)
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:12,代码来源:test_providers.py

示例9: test_provider_add_with_bad_credentials

def test_provider_add_with_bad_credentials(provider):
    """Tests provider add with bad credentials

    Metadata:
        test_flag: crud
    """
    provider.credentials['default'] = get_credentials_from_config('bad_credentials')
    if isinstance(provider, VMwareProvider):
        with error.expected('Cannot complete login due to an incorrect user name or password.'):
            provider.create(validate_credentials=True)
    elif isinstance(provider, RHEVMProvider):
        with error.expected('401 Unauthorized'):
            provider.create(validate_credentials=True)
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:13,代码来源:test_providers.py

示例10: test_delete_categories

def test_delete_categories(rest_api, categories, multiple):
    if "delete" not in rest_api.collections.categories.action.all:
        pytest.skip("Delete categories action is not implemented in this version")

    if multiple:
        rest_api.collections.categories.action.delete(*categories)
        with error.expected("ActiveRecord::RecordNotFound"):
            rest_api.collections.categories.action.delete(*categories)
    else:
        ctg = categories[0]
        ctg.action.delete()
        with error.expected("ActiveRecord::RecordNotFound"):
            ctg.action.delete()
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:13,代码来源:test_rest.py

示例11: test_region_required_validation

def test_region_required_validation(request, soft_assert):
    """Tests to validate the region while adding a provider"""
    prov = EC2Provider(
        name=fauxfactory.gen_alphanumeric(5),
        region=None)

    request.addfinalizer(prov.delete_if_exists)
    if version.current_version() < "5.5":
        with error.expected('Region is not included in the list'):
            prov.create()
    else:
        with error.expected(FlashMessageException):
            prov.create()
        soft_assert("ng-invalid-required" in properties_form.amazon_region_select.classes)
开发者ID:amavinag,项目名称:cfme_tests,代码行数:14,代码来源:test_providers.py

示例12: test_name_required_validation

def test_name_required_validation(request):
    """Tests to validate the name while adding a provider"""
    prov = EC2Provider(
        name=None,
        region='us-east-1')

    request.addfinalizer(prov.delete_if_exists)
    if version.current_version() < "5.5":
        with error.expected("Name can't be blank"):
            prov.create()
    else:
        # It must raise an exception because it keeps on the form
        with error.expected(FlashMessageException):
            prov.create()
        assert prov.properties_form.name_text.angular_help_block == "Required"
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:15,代码来源:test_providers.py

示例13: test_delete_roles

def test_delete_roles(rest_api, roles):
    if "delete" not in rest_api.collections.roles.action.all:
        pytest.skip("Delete roles action is not implemented in this version")

    rest_api.collections.roles.action.delete(*roles)
    with error.expected("ActiveRecord::RecordNotFound"):
        rest_api.collections.roles.action.delete(*roles)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:7,代码来源:test_rest.py

示例14: test_permissions

def test_permissions(appliance, role, allowed_actions, disallowed_actions):
    # create a user and role
    role = role()  # call function to get role
    role.create()
    group = new_group(role=role.name)
    group.create()
    user = new_user(group=group)
    user.create()
    fails = {}
    try:
        with user:
            appliance.server.login_admin()
            for name, action_thunk in allowed_actions.items():
                try:
                    action_thunk()
                except Exception:
                    fails[name] = "{}: {}".format(name, traceback.format_exc())
            for name, action_thunk in disallowed_actions.items():
                try:
                    with error.expected(Exception):
                        action_thunk()
                except error.UnexpectedSuccessException:
                    fails[name] = "{}: {}".format(name, traceback.format_exc())
            if fails:
                message = ''
                for failure in fails.values():
                    message = "{}\n\n{}".format(message, failure)
                raise Exception(message)
    finally:
        appliance.server.login_admin()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:30,代码来源:test_access_control.py

示例15: test_tenant_unique_tenant_project_name_on_parent_level

def test_tenant_unique_tenant_project_name_on_parent_level(request, object_type):
    """Tenant or Project has always unique name on parent level. Same name cannot be used twice.

    Prerequisities:
        * This test is not depending on any other test and can be executed against fresh appliance.

    Steps:
        * Create tenant or project
        * Create another tenant or project with the same name
        * Creation will fail because object with the same name exists
        * Delete created objects
    """

    name_of_tenant = object_type.__name__ + fauxfactory.gen_alphanumeric()
    tenant_description = object_type.__name__ + 'description'

    tenant = object_type(
        name=name_of_tenant,
        description=tenant_description)

    tenant2 = object_type(
        name=name_of_tenant,
        description=tenant_description)

    @request.addfinalizer
    def _delete_tenant():
        if tenant.exists:
            tenant.delete()
        if tenant2.exists:
            tenant2.delete()

    tenant.create()
    with error.expected("Validation failed: Name should be unique per parent"):
        tenant2.create()
    tenant.delete()
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:35,代码来源:test_access_control.py


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