Ejemplo n.º 1
0
    def bench_test(self):
        User.objects.create_user("dillen", "*****@*****.**", "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)
Ejemplo n.º 2
0
    def test_play(self):
        User.objects.create_user("dillen", "*****@*****.**", "letmein")
        User.objects.create_user("eli", "*****@*****.**", "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)