本文整理汇总了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
示例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
)