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


Python hamcrest.has_item方法代码示例

本文整理汇总了Python中hamcrest.has_item方法的典型用法代码示例。如果您正苦于以下问题:Python hamcrest.has_item方法的具体用法?Python hamcrest.has_item怎么用?Python hamcrest.has_item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hamcrest的用法示例。


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

示例1: test_shouldAssesFinalStateProperlyWhenThereIsOnlyOne

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_shouldAssesFinalStateProperlyWhenThereIsOnlyOne(self):
        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")

        workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field")

        transition_meta = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )
        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta,
            priority=0
        )
        assert_that(BasicTestModel.river.my_field.final_states, has_length(1))
        assert_that(list(BasicTestModel.river.my_field.final_states), has_item(state2)) 
开发者ID:javrasya,项目名称:django-river,代码行数:20,代码来源:test__class_api.py

示例2: validate_token_cookies

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def validate_token_cookies(context, expired=False):
    for cookie in context.response.headers.getlist('Set-Cookie'):
        ingredients = _parse_cookie(cookie)
        ingredient_names = list(ingredients.keys())
        if ACCESS_TOKEN_COOKIE_KEY in ingredient_names:
            context.access_token = ingredients[ACCESS_TOKEN_COOKIE_KEY]
        elif REFRESH_TOKEN_COOKIE_KEY in ingredient_names:
            context.refresh_token = ingredients[REFRESH_TOKEN_COOKIE_KEY]
        for ingredient_name in ('Domain', 'Expires', 'Max-Age'):
            assert_that(ingredient_names, has_item(ingredient_name))
        if expired:
            assert_that(ingredients['Max-Age'], equal_to('0'))

    assert hasattr(context, 'access_token'), 'no access token in response'
    assert hasattr(context, 'refresh_token'), 'no refresh token in response'
    if expired:
        assert_that(context.access_token, equal_to(''))
        assert_that(context.refresh_token, equal_to('')) 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:20,代码来源:api.py

示例3: validate_response

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def validate_response(context):
    response_data = context.response.json
    account = context.accounts['foo']
    assert_that(
        response_data['emailAddress'],
        equal_to(account.email_address)
    )
    assert_that(
        response_data['membership']['type'],
        equal_to('Monthly Membership')
    )
    assert_that(response_data['membership']['duration'], none())
    assert_that(
        response_data['membership'], has_item('id')
    )

    assert_that(len(response_data['agreements']), equal_to(3))
    agreement = response_data['agreements'][0]
    assert_that(agreement['type'], equal_to(PRIVACY_POLICY))
    assert_that(
        agreement['acceptDate'],
        equal_to(str(date.today().strftime('%B %d, %Y')))
    )
    assert_that(agreement, has_item('id')) 
开发者ID:MycroftAI,项目名称:selene-backend,代码行数:26,代码来源:profile.py

示例4: test_creating_deleting_a_bond

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_creating_deleting_a_bond(self):
        self.client.add_bond(3)

        list_of_bonds = self.client.get_bonds()
        assert_that(list_of_bonds, has_item(has_properties(number=3)))

        bond = self.client.get_bond(3)
        assert_that(bond, has_properties(number=3))

        self.client.remove_bond(3)

        new_list_of_bonds = self.client.get_bonds()
        assert_that(new_list_of_bonds, is_not(has_item(has_properties(number=3))))

        with self.assertRaises(UnknownBond):
            self.client.get_bond(3) 
开发者ID:internap,项目名称:netman,代码行数:18,代码来源:bond_management_test.py

示例5: verify_raid0

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def verify_raid0(rg):
    assert_that(rg.raid_group_id, equal_to(0))
    assert_that(rg.raid_group_type, equal_to(VNXRaidType.RAID5))
    assert_that(rg.state, equal_to('Valid_luns'))
    assert_that(rg.disks.index,
                has_items('0_0_A0', '0_0_A1', '0_0_A2', '0_0_A3', '0_0_A4'))
    assert_that(rg.list_of_luns, has_item(63868))
    assert_that(len(rg.list_of_luns), equal_to(16))
    assert_that(rg.max_number_of_disks, equal_to(16))
    assert_that(rg.max_number_of_luns, equal_to(256))
    assert_that(rg.raw_capacity_blocks, equal_to(4502487040))
    assert_that(rg.logical_capacity_blocks, equal_to(4502478848))
    assert_that(rg.free_capacity_blocks_non_contiguous,
                equal_to(3744083968))
    assert_that(rg.free_contiguous_group_of_unbound_segments,
                equal_to(1749913216))
    assert_that(rg.defrag_expand_priority, equal_to('N/A'))
    assert_that(rg.percent_defragmented, none())
    assert_that(rg.percent_expanded, none())
    assert_that(rg.disk_expanding_onto, equal_to('N/A'))
    assert_that(rg.lun_expansion_enabled, equal_to(False))
    assert_that(rg.legal_raid_types[0], equal_to(VNXRaidType.RAID5)) 
开发者ID:emc-openstack,项目名称:storops,代码行数:24,代码来源:verifiers.py

示例6: test_show_run_vs_show_run_interface_same_output

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_show_run_vs_show_run_interface_same_output(self, t):
        enable(t)
        configuring_interface(t, "ethernet 1/g1", do="shutdown")
        assert_interface_configuration(t, "ethernet 1/g1", [
            "shutdown"
        ])

        assert_running_config_contains_in_order(t, [
            "interface ethernet 1/g1",
            "shutdown",
            "exit",
            "!",
        ])

        configuring_interface(t, "ethernet 1/g1", do="no shutdown")

        assert_interface_configuration(t, "ethernet 1/g1", [
            ""
        ])

        config = get_running_config(t)
        assert_that(config, is_not(has_item("interface ethernet 1/g1"))) 
开发者ID:internap,项目名称:fake-switches,代码行数:24,代码来源:test_configure_interface.py

示例7: test_show_run_vs_show_run_interface_same_output

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_show_run_vs_show_run_interface_same_output(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="shutdown")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            "shutdown"
        ])

        assert_running_config_contains_in_order(t, [
            "interface tengigabitethernet 0/0/1",
            "shutdown",
            "exit",
            "!",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            ""
        ])

        config = get_running_config(t)
        assert_that(config, is_not(has_item("interface tengigabitethernet 0/0/1"))) 
开发者ID:internap,项目名称:fake-switches,代码行数:24,代码来源:test_configure_interface.py

示例8: test_shouldNotDeleteApprovedTransitionWhenDeleted

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_shouldNotDeleteApprovedTransitionWhenDeleted(self):
        content_type = ContentType.objects.get_for_model(BasicTestModel)

        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")

        workflow = WorkflowFactory(initial_state=state1, content_type=content_type, field_name="my_field")

        transition_meta = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )
        meta1 = TransitionApprovalMetaFactory.create(workflow=workflow, transition_meta=transition_meta, priority=0)

        BasicTestModelObjectFactory()
        TransitionApproval.objects.filter(workflow=workflow).update(status=APPROVED)
        approvals = TransitionApproval.objects.filter(workflow=workflow)
        assert_that(approvals, has_length(1))
        assert_that(approvals, has_item(has_property("meta", meta1)))

        meta1.delete()

        approvals = TransitionApproval.objects.filter(workflow=workflow)
        assert_that(approvals, has_length(1))
        assert_that(approvals, has_item(has_property("meta", none()))) 
开发者ID:javrasya,项目名称:django-river,代码行数:28,代码来源:test__transition_approval_meta.py

示例9: test__shouldInjectExistingAdminOfTheModelThatHasStateFieldInIt

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test__shouldInjectExistingAdminOfTheModelThatHasStateFieldInIt(self):
        assert_that(admin.site._registry[BasicTestModel], instance_of(BasicTestModelAdmin))
        assert_that(admin.site._registry[BasicTestModel].inlines, has_item(OnApprovedHookInline))
        assert_that(admin.site._registry[BasicTestModel].inlines, has_item(OnTransitHookInline))
        assert_that(admin.site._registry[BasicTestModel].inlines, has_item(OnCompleteHookInline)) 
开发者ID:javrasya,项目名称:django-river,代码行数:7,代码来源:test__app.py

示例10: test__shouldInjectADefaultAdminWithTheHooks

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test__shouldInjectADefaultAdminWithTheHooks(self):
        assert_that(admin.site._registry[BasicTestModelWithoutAdmin], instance_of(DefaultWorkflowModelAdmin))
        assert_that(admin.site._registry[BasicTestModel].inlines, has_item(OnApprovedHookInline))
        assert_that(admin.site._registry[BasicTestModel].inlines, has_item(OnTransitHookInline))
        assert_that(admin.site._registry[BasicTestModel].inlines, has_item(OnCompleteHookInline)) 
开发者ID:javrasya,项目名称:django-river,代码行数:7,代码来源:test__app.py

示例11: test__shouldNotInjectToAdminOfTheModelThatDoesNotHaveStateFieldInIt

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test__shouldNotInjectToAdminOfTheModelThatDoesNotHaveStateFieldInIt(self):
        assert_that(admin.site._registry[Function].inlines, is_not(has_item(OnApprovedHookInline)))
        assert_that(admin.site._registry[Function].inlines, is_not(has_item(OnTransitHookInline)))
        assert_that(admin.site._registry[Function].inlines, is_not(has_item(OnCompleteHookInline))) 
开发者ID:javrasya,项目名称:django-river,代码行数:6,代码来源:test__app.py

示例12: test_shouldReturnAnApprovalWhenUserIsAuthorizedWithAPermission

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_shouldReturnAnApprovalWhenUserIsAuthorizedWithAPermission(self):
        authorized_permission = PermissionObjectFactory()
        authorized_user = UserObjectFactory(user_permissions=[authorized_permission])

        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")

        workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field")

        transition_meta = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )
        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta,
            priority=0,
            permissions=[authorized_permission]
        )

        workflow_object = BasicTestModelObjectFactory()

        available_approvals = BasicTestModel.river.my_field.get_available_approvals(as_user=authorized_user)
        assert_that(available_approvals, has_length(1))
        assert_that(list(available_approvals), has_item(
            all_of(
                has_property("workflow_object", workflow_object.model),
                has_property("workflow", workflow),
                has_property("transition", transition_meta.transitions.first())
            )
        )) 
开发者ID:javrasya,项目名称:django-river,代码行数:34,代码来源:test__class_api.py

示例13: test_shouldReturnAnApprovalWhenUserIsAuthorizedAsTransactioner

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_shouldReturnAnApprovalWhenUserIsAuthorizedAsTransactioner(self):
        authorized_user = UserObjectFactory()

        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")

        workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field")

        transition_meta = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )
        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta,
            priority=0
        )

        workflow_object = BasicTestModelObjectFactory()

        TransitionApproval.objects.filter(workflow_object=workflow_object.model).update(transactioner=authorized_user)

        available_approvals = BasicTestModel.river.my_field.get_available_approvals(as_user=authorized_user)
        assert_that(available_approvals, has_length(1))
        assert_that(list(available_approvals), has_item(
            all_of(
                has_property("workflow_object", workflow_object.model),
                has_property("workflow", workflow),
                has_property("transition", transition_meta.transitions.first())
            )
        )) 
开发者ID:javrasya,项目名称:django-river,代码行数:34,代码来源:test__class_api.py

示例14: test_shouldNotReturnOtherObjectsApprovalsForTheAuthorizedUser

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test_shouldNotReturnOtherObjectsApprovalsForTheAuthorizedUser(self):
        authorized_permission = PermissionObjectFactory()
        authorized_user = UserObjectFactory(user_permissions=[authorized_permission])

        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")
        workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field")
        transition_meta = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )
        TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta,
            priority=0,
            permissions=[authorized_permission]

        )

        workflow_object1 = BasicTestModelObjectFactory()
        workflow_object2 = BasicTestModelObjectFactory()

        available_approvals = workflow_object1.model.river.my_field.get_available_approvals(as_user=authorized_user)
        assert_that(available_approvals, has_length(1))
        assert_that(list(available_approvals), has_item(
            has_property("workflow_object", workflow_object1.model)
        ))
        assert_that(list(available_approvals), has_item(
            is_not(has_property("workflow_object", workflow_object2.model))
        )) 
开发者ID:javrasya,项目名称:django-river,代码行数:33,代码来源:test__instance_api.py

示例15: test__shouldReturnNextApprovals

# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import has_item [as 别名]
def test__shouldReturnNextApprovals(self):
        state1 = StateObjectFactory(label="state1")
        state2 = StateObjectFactory(label="state2")
        state3 = StateObjectFactory(label="state3")

        workflow = WorkflowFactory(initial_state=state1, content_type=self.content_type, field_name="my_field")

        transition_meta_1 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state2,
        )

        transition_meta_2 = TransitionMetaFactory.create(
            workflow=workflow,
            source_state=state1,
            destination_state=state3,
        )

        meta1 = TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_1,
            priority=0,
        )

        meta2 = TransitionApprovalMetaFactory.create(
            workflow=workflow,
            transition_meta=transition_meta_2,
            priority=0,
        )

        workflow_object = BasicTestModelObjectFactory()

        assert_that(workflow_object.model.my_field, equal_to(state1))
        next_approvals = workflow_object.model.river.my_field.next_approvals
        assert_that(next_approvals, has_length(2))
        assert_that(next_approvals, has_item(meta1.transition_approvals.first()))
        assert_that(next_approvals, has_item(meta2.transition_approvals.first())) 
开发者ID:javrasya,项目名称:django-river,代码行数:40,代码来源:test__instance_api.py


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