Skip to content

Commit

Permalink
55 stat id map not populated in league resource (#57)
Browse files Browse the repository at this point in the history
Co-authored-by: DMcP89 <DMcP89@users.noreply.github.com>
  • Loading branch information
DMcP89 and DMcP89 authored Feb 2, 2025
1 parent 4060127 commit 72be91e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def readme():


setup(name='yahoo_fantasy_api',
version='2.10.0',
version='2.10.1',
description='Python bindings to access the Yahoo! Fantasy APIs',
long_description=readme(),
url='http://github.com/spilchen/yahoo_fantasy_api',
Expand Down
3 changes: 1 addition & 2 deletions yahoo_fantasy_api/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def to_league(self, league_id):
:return: Fully constructed object
:rtype: League
"""
lg = league.League(self.sc, league_id)
lg.inject_yhandler(self.yhandler)
lg = league.League(self.sc, league_id, handler=self.yhandler)
return lg

def league_ids(self, year=None):
Expand Down
10 changes: 8 additions & 2 deletions yahoo_fantasy_api/league.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ class League:
:type league_id: str
"""

def __init__(self, sc, league_id):
def __init__(self, sc, league_id, handler=None):
self.sc = sc
self.league_id = league_id
self.yhandler = yhandler.YHandler(sc)
if handler:
self.yhandler = handler
else:
self.yhandler = yhandler.YHandler(sc)
self.current_week_cache = None
self.end_week_cache = None
self.week_date_range_cache = {}
Expand All @@ -33,6 +36,9 @@ def __init__(self, sc, league_id):
self.positions_cache = None
self.stats_id_map = None
self.player_details_cache = {}
lg_settings = self.settings()
game_code = lg_settings['game_code']
self._cache_stats_id_map(game_code)

def inject_yhandler(self, yhandler):
self.yhandler = yhandler
Expand Down
9 changes: 3 additions & 6 deletions yahoo_fantasy_api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ def sc():

@pytest.fixture()
def mock_mlb_league(sc):
lg = yfa.League(sc, '370.l.56877')
lg.inject_yhandler(mock_yhandler.YHandler())
lg = yfa.League(sc, '370.l.56877', handler=mock_yhandler.YHandler())
yield lg


@pytest.fixture()
def mock_nhl_league(sc):
lg = yfa.League(sc, '396.l.21484')
lg.inject_yhandler(mock_yhandler.YHandler())
lg = yfa.League(sc, '396.l.21484', handler=mock_yhandler.YHandler())
yield lg


@pytest.fixture()
def mock_nfl_league(sc):
lg = yfa.League(sc, '449.l.75178')
lg.inject_yhandler(mock_yhandler.YHandler())
lg = yfa.League(sc, '449.l.75178', handler=mock_yhandler.YHandler())
yield lg


Expand Down

0 comments on commit 72be91e

Please sign in to comment.