Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyagreco committed Sep 13, 2023
1 parent 9fd73d3 commit 6178d03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
## Unreleased

- Fixed bug where Sleeper leagues without divisions would fail to load
- Fixed bug where Yahoo leagues could not load league IDs for previous years

## [2.5.3]

Expand Down
7 changes: 6 additions & 1 deletion leeger/league_loader/YahooLeagueLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def __getAllLeagues(self) -> list[YahooLeague]:
if str(league.league_id) == currentLeagueId:
yahooLeagues.append(league)
foundLeagueForYear = True
previousLeagueId = league.past_league_id
try:
# NOTE: this is weird. apparently the league ID here is returned like this: (414, 957486)
# NOTE: and the league id is always at index 1
previousLeagueId = str(league.past_league_id[1])
except Exception as e:
self._LOGGER.warning(f"could not get previous league id: {e}")
if not foundLeagueForYear:
raise LeagueLoaderException(
f"Could not find league for year {year} with ID {currentLeagueId}."
Expand Down
6 changes: 3 additions & 3 deletions test/test_league_loader/test_YahooLeagueLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_loadLeague_happyPath(
mockLeague2023.season = 2023
mockLeague2023.current_week = 3
mockLeague2023.end_week = 3
mockLeague2023.past_league_id = "123"
mockLeague2023.past_league_id = ["", "123"]

# mock fake leagues 2023
mockLeague2023_fake1 = Mock()
Expand Down Expand Up @@ -665,7 +665,7 @@ def test_loadLeague_withOwnerNamesAndAliases(
mockLeague2023.season = 2023
mockLeague2023.current_week = 3
mockLeague2023.end_week = 3
mockLeague2023.past_league_id = "123"
mockLeague2023.past_league_id = ["", "123"]

# mock fake leagues 2023
mockLeague2023_fake1 = Mock()
Expand Down Expand Up @@ -1226,7 +1226,7 @@ def test_loadLeague_happyPath(
mockLeague2023.season = 2023
mockLeague2023.current_week = 3
mockLeague2023.end_week = 3
mockLeague2023.past_league_id = "123"
mockLeague2023.past_league_id = ["", "123"]

# mock fake leagues 2023
mockLeague2023_fake1 = Mock()
Expand Down

0 comments on commit 6178d03

Please sign in to comment.