本文整理汇总了Python中models.Team.wr_count方法的典型用法代码示例。如果您正苦于以下问题:Python Team.wr_count方法的具体用法?Python Team.wr_count怎么用?Python Team.wr_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team
的用法示例。
在下文中一共展示了Team.wr_count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bench_test
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import wr_count [as 别名]
def bench_test(self):
User.objects.create_user("dillen", "[email protected]", "letmein")
team1 = Team(team_name="Winners",owner=User.objects.get(username__exact="dillen"))
p1 = Player(full_name="abc1",position="WR",team=team1,benched=False)
p2 = Player(full_name="abc2",position="WR",team=team1,benched=False)
team1.wr_count = 2
p3 = Player(full_name="abc3",position="WR",team=team1)
p4 = Player(full_name="abc4",position="WR")
team1.save()
p1.save()
p2.save()
p3.save()
p4.save()
#Bench someone already benched
self.assertEqual(bench(p3),False)
self.assertEqual(team1.wr_count,2)
self.assertEqual(p3.benched,True)
#Bench someone not on a team
self.assertEqual(bench(p4),False)
self.assertEqual(team1.wr_count,2)
self.assertEqual(p4.benched,True)
#Bench a WR
self.assertEqual(bench(p2),False)
self.assertEqual(team1.wr_count,1)
self.assertEqual(p1.benched,False)
self.assertEqual(p2.benched,True)
示例2: test_play
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import wr_count [as 别名]
def test_play(self):
User.objects.create_user("dillen", "[email protected]", "letmein")
User.objects.create_user("eli", "[email protected]", "letmein")
team1 = Team(team_name="Winners",owner=User.objects.get(username__exact="dillen"))
p1 = Player(full_name="abc1",position="WR",team=team1,benched=False)
team1.wr_count = 1
p2 = Player(full_name="abc2",position="WR",team=team1)
p3 = Player(full_name="abc3",position="WR")
p4 = Player(full_name="abc4",position="QB",team=team1,benched=False)
team1.qb_count = 1
p5 = Player(full_name="abc5",position="QB",team=team1)
team1.save()
p1.save()
p2.save()
p3.save()
p4.save()
p5.save()
#Wrong position
self.assertEqual(play(p2,"QB"),False)
self.assertEqual(p2.benched,True)
self.assertEqual(team1.qb_count,1)
#Already playing
self.assertEqual(play(p1,"WR"),False)
self.assertEqual(p1.benched,False)
self.assertEqual(team1.wr_count,1)
#Not on a team
self.assertEqual(play(p3,"WR"),False)
self.assertEqual(p3.team, None)
self.assertEqual(p3.benched, True)
self.assertEqual(team1.wr_count,1)
#2 QB's at the same time
self.assertEqual(play(p5,"QB"),False)
self.assertEqual(p4.benched, False)
self.assertEqual(p5.benched, True)
self.assertEqual(team1.qb_count,1)
#2 WR's at the same time (valid)
self.assertEqual(play(p2,"WR"),True)
self.assertEqual(p2.benched, False)
self.assertEqual(team1.wr_count,2)