Skip to content

Commit

Permalink
Merge pull request #425 from cwendt94/bb_add_draft_test
Browse files Browse the repository at this point in the history
Add Basketball Draft Test
  • Loading branch information
cwendt94 authored Dec 16, 2022
2 parents 6c33c3f + 56d1dc7 commit 570cbae
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions tests/basketball/integration/test_league.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,50 @@

# 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')
self.assertEqual(player.stats['2']['team'], 'BKN')
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)
Expand Down

0 comments on commit 570cbae

Please sign in to comment.