Exemplo n.º 1
0
 def test_team_add_remove(self):
     common.add_player_to_team(user=self.player1, player=self.player1, season=self.season_open, team=self.team)
     self.assertEqual(
         1,
         common.TeamPlayerSeason.objects.filter(
             player=self.player1, season=self.season_open, team=self.team
         ).count(),
     )
     common.add_player_to_team(
         user=self.player2, player=self.player2, season=self.season_open, team=self.team, is_captain=True
     )
     self.assertTrue(self.player2.is_captain(self.team, self.season_open))
     self.assertEqual(2, len(common.find_players_on(self.team, self.season_open)))
     common.remove_player_from_team(user=self.player1, player=self.player1, season=self.season_open, team=self.team)
     self.assertEqual(1, len(common.find_players_on(self.team, self.season_open)))
     common.add_player_to_team(user=self.player1, player=self.player1, season=self.season_open, team=self.team)
     self.assertEqual(2, len(common.find_players_on(self.team, self.season_open)))
     common.remove_player_from_team(user=self.player2, player=self.player1, season=self.season_open, team=self.team)
     self.assertEqual(1, len(common.find_players_on(self.team, self.season_open)))
Exemplo n.º 2
0
 def test_remove_player(self):
     self.assertFalse(self.player1.is_superuser())
     self.assertFalse(self.player1.is_captain(self.team, self.season_open))
     common.add_player_to_team(user=self.player1, player=self.player1, season=self.season_open, team=self.team)
     common.add_player_to_team(
         user=self.player2, player=self.player2, season=self.season_open, team=self.team, is_captain=True
     )
     # cannot remove another if you are not a captain
     self.assertRaisesMessage(
         common.PermissionsException,
         common.PermissionsException.MSG_CAPTAIN_REMOVE,
         common.remove_player_from_team,
         user=self.player1,
         player=self.player2,
         season=self.season_open,
         team=self.team,
     )
     self.assertEqual(2, len(common.find_players_on(self.team, self.season_open)))
     common.remove_player_from_team(user=self.player2, player=self.player1, season=self.season_open, team=self.team)
     self.assertEqual(1, len(common.find_players_on(self.team, self.season_open)))
Exemplo n.º 3
0
 def _test_create_teams_from(self, expected_ranks, serpentine):
     rating.create_teams_from(self.rankset_teams, serpentine=serpentine)
     pick_order = self.rankset_teams.pick_order.all()
     for pick in pick_order:
         team = pick.team
         real_ranks = []
         players = common.find_players_on(team, self.rankset_teams.season)
         for player in players:
             player_rank = rating.PlayerRanking.objects.get(rankset=self.rankset_teams, player=player)
             real_ranks.append(player_rank.rank)
         #print set(real_ranks), expected_ranks[pick.rank]
         self.assertEqual(set(real_ranks), expected_ranks[pick.rank])
Exemplo n.º 4
0
 def test_find_players_on(self):
     self.assertEquals(self.player3, common.find_players_on(self.team, self.season_old)[0])
     self.assertEquals(0, len(common.find_players_on(self.team, self.season_active)))