From 56d1dc7f48a9adb27e06942d77b3afad0337f40c Mon Sep 17 00:00:00 2001 From: Christian Wendt Date: Fri, 16 Dec 2022 16:51:39 +0000 Subject: [PATCH] Add Basketball Draft Test --- tests/basketball/integration/test_league.py | 33 ++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/basketball/integration/test_league.py b/tests/basketball/integration/test_league.py index f74548ba..b85ab947 100644 --- a/tests/basketball/integration/test_league.py +++ b/tests/basketball/integration/test_league.py @@ -3,33 +3,39 @@ # Integration test to make sure ESPN's API didn't change class LeagueTest(TestCase): + def setUp(self): + self.league = League(411647, 2019) def test_league_init(self): - league = League(411647, 2019) - self.assertEqual(league.scoringPeriodId, 178) - player = league.teams[0].roster[0] + self.assertEqual(self.league.scoringPeriodId, 178) + player = self.league.teams[0].roster[0] self.assertEqual(player.schedule['2']['team'], 'BKN') self.assertEqual(player.total_points, 3583.0) self.assertEqual(player.avg_points, 45.35) def test_league_scoreboard(self): - league = League(411647, 2019) - scores = league.scoreboard() + scores = self.league.scoreboard() self.assertEqual(scores[0].home_final_score, 4240.0) self.assertEqual(scores[0].away_final_score, 2965.0) + + def test_league_draft(self): + draft = self.league.draft + + self.assertEqual(draft[1].playerName, 'LeBron James') + self.assertEqual(draft[1].round_num, 1) + self.assertEqual(draft[2].round_pick, 3) + self.assertEqual(draft[2].team.team_name, 'Denver Nuggets ') def test_league_free_agents(self): - league = League(411647, 2019) - free_agents = league.free_agents() + free_agents = self.league.free_agents() self.assertNotEqual(len(free_agents), 0) def test_player_info(self): - league = League(411647, 2019) - player_id = league.teams[0].roster[0].playerId + player_id = self.league.teams[0].roster[0].playerId - player = league.player_info(playerId=player_id) + player = self.league.player_info(playerId=player_id) self.assertEqual(player.__repr__(), 'Player(Andre Drummond)') self.assertEqual(player.schedule['2']['team'], 'BKN') @@ -37,11 +43,10 @@ def test_player_info(self): self.assertEqual(player.stats['2']['total']['PTS'], 24.0) def test_league_box_scores(self): - league = League(411647, 2019) - final_matchup = league.box_scores()[0] - middle_matchup = league.box_scores(matchup_period=7)[0] + final_matchup = self.league.box_scores()[0] + middle_matchup = self.league.box_scores(matchup_period=7)[0] # same matchup period but single scoring period - scoring_period_matchup = league.box_scores(scoring_period=48, matchup_total=False)[0] + scoring_period_matchup = self.league.box_scores(scoring_period=48, matchup_total=False)[0] self.assertEqual(final_matchup.home_score, 4240.0) self.assertEqual(final_matchup.away_lineup[0].points, 156.0)