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)))