From 0e39576ac7515cac9db0f85cd20bdc5ced99c2ab Mon Sep 17 00:00:00 2001 From: Christian Wendt Date: Thu, 25 Apr 2024 15:27:21 +0000 Subject: [PATCH] Update ESPN API Base Endpoint --- espn_api/requests/constant.py | 3 +-- tests/football/unit/test_league.py | 7 ++++--- tests/football/unit/test_past_league.py | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/espn_api/requests/constant.py b/espn_api/requests/constant.py index d7900dc4..853a94f0 100644 --- a/espn_api/requests/constant.py +++ b/espn_api/requests/constant.py @@ -1,5 +1,4 @@ -FANTASY_BASE_ENDPOINT = 'https://fantasy.espn.com/apis/v3/games/' - +FANTASY_BASE_ENDPOINT = 'https://lm-api-reads.fantasy.espn.com/apis/v3/games/' FANTASY_SPORTS = { 'nfl' : 'ffl', 'nba' : 'fba', diff --git a/tests/football/unit/test_league.py b/tests/football/unit/test_league.py index 6b6a606a..a8d2aebc 100644 --- a/tests/football/unit/test_league.py +++ b/tests/football/unit/test_league.py @@ -1,5 +1,6 @@ from unittest import mock, TestCase from espn_api.football import League, BoxPlayer +from espn_api.requests.constant import FANTASY_BASE_ENDPOINT from espn_api.football.helper import ( build_division_record_dict, build_h2h_dict, @@ -19,8 +20,8 @@ class LeagueTest(TestCase): def setUp(self): self.league_id = 123 self.season = 2018 - self.espn_endpoint = "https://fantasy.espn.com/apis/v3/games/FFL/seasons/" + str(self.season) + "/segments/0/leagues/" + str(self.league_id) - self.players_endpoint = 'https://fantasy.espn.com/apis/v3/games/ffl/seasons/' + str(self.season) + '/players?view=players_wl' + self.espn_endpoint = FANTASY_BASE_ENDPOINT + 'FFL/seasons/' + str(self.season) + '/segments/0/leagues/' + str(self.league_id) + self.players_endpoint = FANTASY_BASE_ENDPOINT + 'ffl/seasons/' + str(self.season) + '/players?view=players_wl' with open('tests/football/unit/data/league_2018_data.json') as data: self.league_data = json.loads(data.read()) with open('tests/football/unit/data/league_draft_2018.json') as data: @@ -462,7 +463,7 @@ def test_recent_activity(self, m): # TODO hack until I get all mock data for 2019 league.year = 2019 - self.espn_endpoint = "https://fantasy.espn.com/apis/v3/games/ffl/seasons/" + str(2019) + "/segments/0/leagues/" + str(self.league_id) + self.espn_endpoint = FANTASY_BASE_ENDPOINT + 'ffl/seasons/' + str(2019) + '/segments/0/leagues/' + str(self.league_id) league.espn_request.LEAGUE_ENDPOINT = self.espn_endpoint with open('tests/football/unit/data/league_recent_activity_2019.json') as f: diff --git a/tests/football/unit/test_past_league.py b/tests/football/unit/test_past_league.py index 5c632209..8541bf48 100644 --- a/tests/football/unit/test_past_league.py +++ b/tests/football/unit/test_past_league.py @@ -1,5 +1,6 @@ from unittest import mock, TestCase from espn_api.football import League +from espn_api.requests.constant import FANTASY_BASE_ENDPOINT import requests_mock import json @@ -9,8 +10,8 @@ class LeaguePastTest(TestCase): def setUp(self): self.league_id = 123 self.season = 2015 - self.espn_endpoint = "https://fantasy.espn.com/apis/v3/games/ffl/leagueHistory/" + str(self.league_id) + "?seasonId=2015" - self.players_endpoint = 'https://fantasy.espn.com/apis/v3/games/ffl/seasons/' + str(self.season) + '/players?view=players_wl' + self.espn_endpoint = FANTASY_BASE_ENDPOINT + 'ffl/leagueHistory/' + str(self.league_id) + '?seasonId=2015' + self.players_endpoint = FANTASY_BASE_ENDPOINT + 'ffl/seasons/' + str(self.season) + '/players?view=players_wl' with open('tests/football/unit/data/league_2015_data.json') as data: self.league_data = json.loads(data.read()) with open('tests/football/unit/data/league_draft_2015.json') as data: