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


Python TeamFactory.get_members方法代码示例

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


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

示例1: test_team_member_addition

# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import get_members [as 别名]
def test_team_member_addition(client, TwoChallengeSets):
    team = TeamFactory(
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        owner=TwoChallengeSets.ChallengeSet1.participant,
    )
    assert TwoChallengeSets.ChallengeSet1.participant in team.get_members()
    assert (
        TwoChallengeSets.ChallengeSet1.participant1 not in team.get_members()
    )
    # Participant1 requests to join team
    response = get_view_for_user(
        viewname="teams:member-create",
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        client=client,
        method=client.post,
        user=TwoChallengeSets.ChallengeSet1.participant1,
        reverse_kwargs={"pk": team.pk},
    )
    assert TwoChallengeSets.ChallengeSet1.participant1 in team.get_members()
    assert response.status_code == 302
开发者ID:comic,项目名称:comic-django,代码行数:22,代码来源:test_views.py

示例2: test_unique_membership

# 需要导入模块: from tests.factories import TeamFactory [as 别名]
# 或者: from tests.factories.TeamFactory import get_members [as 别名]
def test_unique_membership(client, TwoChallengeSets):
    team = TeamFactory(
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        owner=TwoChallengeSets.ChallengeSet1.participant,
    )
    team1 = TeamFactory(
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        owner=TwoChallengeSets.ChallengeSet1.participant1,
    )
    # Try to create a new team, should be denied
    response = get_view_for_user(
        viewname="teams:create",
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        client=client,
        method=client.post,
        user=TwoChallengeSets.ChallengeSet1.participant,
        data={"name": "thisteamshouldnotbecreated"},
    )
    assert response.status_code == 200
    assert (
        "You are already a member of another team for this challenge"
        in response.rendered_content
    )
    # Participant1 requests to join team, should be denied
    response = get_view_for_user(
        viewname="teams:member-create",
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        client=client,
        method=client.post,
        user=TwoChallengeSets.ChallengeSet1.participant1,
        reverse_kwargs={"pk": team.pk},
    )
    assert response.status_code == 200
    assert (
        "You are already a member of another team for this challenge"
        in response.rendered_content
    )
    # participant12 should be able to create a team in their challenge and join another
    response = get_view_for_user(
        viewname="teams:create",
        challenge=TwoChallengeSets.ChallengeSet2.challenge,
        client=client,
        method=client.post,
        user=TwoChallengeSets.participant12,
        data={"name": "thisteamshouldbecreated"},
    )
    assert response.status_code == 302
    response = get_view_for_user(
        viewname="teams:member-create",
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        client=client,
        method=client.post,
        user=TwoChallengeSets.participant12,
        reverse_kwargs={"pk": team.pk},
    )
    assert response.status_code == 302
    assert TwoChallengeSets.participant12 in team.get_members()
    response = get_view_for_user(
        viewname="teams:member-create",
        challenge=TwoChallengeSets.ChallengeSet1.challenge,
        client=client,
        method=client.post,
        user=TwoChallengeSets.participant12,
        reverse_kwargs={"pk": team1.pk},
    )
    assert response.status_code == 200
    assert (
        "You are already a member of another team for this challenge"
        in response.rendered_content
    )
开发者ID:comic,项目名称:comic-django,代码行数:72,代码来源:test_views.py


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