Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2018 Fantasy Football API Update #615

Merged
merged 17 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixed typo in LEAGUE_ENDPOINT URL in assert equal test
Robert Litts committed Jan 7, 2025
commit a7178486f22db6723563767350acf0c9e5e66e02
2 changes: 1 addition & 1 deletion tests/football/integration/test_league.py
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ def test_private_league(self):
''' Test for switching to fallback API endpoint for private leagues. Random, incorrect cookies used to force fallback. '''
league = League(368876, 2018, 'AEF1234567890ABCDE1234567890ABCD', '{D0C25A4C-2A0D-4E56-8E7F-20A10B663272}')

self.assertEqual(league.espn_request.LEAGUE_ENDPOINT, "https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/leagueHistory/36887?seasonId=2018")
self.assertEqual(league.espn_request.LEAGUE_ENDPOINT, "https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/leagueHistory/368876?seasonId=2018")

def test_unknown_league(self):
with self.assertRaises(Exception):

Unchanged files with check annotations Beta

if status == 401:
# If the current LEAGUE_ENDPOINT was using the /leagueHistory/ endpoint, switch to "/seasons/" endpoint
if "/leagueHistory/" in self.LEAGUE_ENDPOINT:
base_endpoint = self.LEAGUE_ENDPOINT.split("/leagueHistory/")[0]
self.LEAGUE_ENDPOINT = f"{base_endpoint}/seasons/{self.year}/segments/0/leagues/{self.league_id}"

Check warning on line 43 in espn_api/requests/espn_requests.py

Codecov / codecov/patch

espn_api/requests/espn_requests.py#L42-L43

Added lines #L42 - L43 were not covered by tests
else:
# If the current LEAGUE_ENDPOINT was using /seasons, switch to the "/leagueHistory/" endpoint
base_endpoint = self.LEAGUE_ENDPOINT.split(f"/seasons/")[0]
return r.json()
# If all endpoints failed, raise the corresponding error
raise ESPNAccessDenied(f"League {self.league_id} cannot be accessed with espn_s2={self.cookies.get('espn_s2')} and swid={self.cookies.get('SWID')}")

Check warning on line 57 in espn_api/requests/espn_requests.py

Codecov / codecov/patch

espn_api/requests/espn_requests.py#L57

Added line #L57 was not covered by tests
elif status == 404:
raise ESPNInvalidLeague(f"League {self.league_id} does not exist")