Skip to content

Commit

Permalink
Add tests for box_scores
Browse files Browse the repository at this point in the history
  • Loading branch information
cwendt94 committed Feb 3, 2023
1 parent e1341f2 commit c85a478
Show file tree
Hide file tree
Showing 6 changed files with 52,350 additions and 223 deletions.
4 changes: 2 additions & 2 deletions espn_api/basketball/box_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _get_team_data(self, team_data, pro_schedule, by_matchup, year):
wins = cumulative_score.get('wins', 0)
ties = cumulative_score.get('ties', 0)
losses = cumulative_score.get('losses', 0)
points = team.get('totalPointsLive') if 'totalPointsLive' in team else team.get('totalPoints', 0)
points = team_data.get('totalPointsLive') if 'totalPointsLive' in team_data else team_data.get('totalPoints', 0)

stats = {}
for stat_key, stat_dict in cumulative_score.get('scoreByStat', {}).items():
Expand All @@ -87,7 +87,7 @@ def _get_team_data(self, team_data, pro_schedule, by_matchup, year):
}
lineup = get_player_lineup(team_data, pro_schedule, by_matchup, year)

return { team, wins, ties, losses, points, stats, lineup }
return { 'team': team, 'wins': wins, 'ties': ties, 'losses': losses, 'points': points, 'stats': stats, 'lineup': lineup }



Expand Down
5 changes: 3 additions & 2 deletions espn_api/basketball/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ def box_scores(self, matchup_period: int = None, scoring_period: int = None, mat
pro_schedule = self._get_pro_schedule(scoring_id)
box_data = [self.BoxScoreClass(matchup, pro_schedule, matchup_total, self.year) for matchup in schedule]

# TODO add mapping for roto teams
for team in self.teams:
for matchup in box_data:
if matchup.home_team == team.team_id:
if hasattr(matchup, 'home_team') and matchup.home_team == team.team_id:
matchup.home_team = team
elif matchup.away_team == team.team_id:
elif hasattr(matchup, 'away_team') and matchup.away_team == team.team_id:
matchup.away_team = team
return box_data

Expand Down
Loading

0 comments on commit c85a478

Please sign in to comment.