Skip to content

Commit

Permalink
Updates package resource loading to use files() instead of soon-to-be…
Browse files Browse the repository at this point in the history
…-deprecated open_text()
  • Loading branch information
coreyjs committed Nov 26, 2023
1 parent 11a0a01 commit dc1bc6d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nhlpy/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Should this be driven by the main pyproject.toml file? yes, is it super convoluted? yes, can it wait? sure

__version__ = "2.1.4"
__version__ = "2.1.5"
4 changes: 2 additions & 2 deletions nhlpy/api/standings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def get_standings(self, date: Optional[str] = None, season: Optional[str] = None
# load json from data/seasonal_information_manifest.json
import json

with importlib.resources.open_text("nhlpy.data", "seasonal_information_manifest.json") as f:
seasons = json.load(f)["seasons"]
data_resource = importlib.resources.files("nhlpy") / "data"
seasons = json.loads((data_resource / "seasonal_information_manifest.json").read_text())["seasons"]
else:
seasons = self.season_standing_manifest()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "nhl-api-py"
version = "2.1.4"
version = "2.1.5"
description = "NHL API. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods for easy data loading in Pandas or any ML applications."
authors = ["Corey Schaf <cschaf@gmail.com>"]
readme = "README.md"
Expand Down
6 changes: 6 additions & 0 deletions tests/test_standings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ def test_get_standings(h_m, nhl_client):
nhl_client.standings.get_standings()
h_m.assert_called_once()
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/standings/now"


@mock.patch("httpx.get")
def test_get_standings_with_cache_load(h_m, nhl_client):
nhl_client.standings.get_standings(season="20202021", cache=True)
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/standings/2021-05-19"

0 comments on commit dc1bc6d

Please sign in to comment.