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

59 utah #60

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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.7.1"
__version__ = "2.8.0"
19 changes: 0 additions & 19 deletions nhlpy/api/teams.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import importlib.resources
from warnings import warn
from typing import List

from nhlpy.http_client import HttpClient
Expand All @@ -12,29 +11,11 @@ def __init__(self, http_client: HttpClient) -> None:
self.base_url = "https://api.nhle.com"
self.api_ver = "/stats/rest/"

# todo deprecate this
def team_stats_summary(self, lang="en") -> List[dict]:
"""
I really don't know what this endpoint does. It returns a list of dicts with team stats.
:param lang: Language param. 'en' for English, 'fr' for French
:return:
"""
warn(
"This endpoint will be deprecated in the future. Use stats.team_summary() instead.",
DeprecationWarning,
stacklevel=2,
)
return self.client.get_by_url(full_resource=f"{self.base_url}{self.api_ver}{lang}/team/summary").json()["data"]

def teams_info(self) -> dict:
"""
Returns a list of dicts with all the teams info. This is loaded via a harccoded json file.
:return: dict
"""

# with importlib.resources.files("nhlpy.data", "teams_20232024.json") as f:
# return json.load(f)['teams']

data_resource = importlib.resources.files("nhlpy") / "data"
teams_info = json.loads((data_resource / "teams_20232024.json").read_text())["teams"]
return teams_info
Expand Down
8 changes: 7 additions & 1 deletion nhlpy/data/team_stat_ids.json
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@
"fullName": "Seattle Kraken",
"teamCommonName": "Kraken",
"teamPlaceName": "Seattle"
},
{
"id": 40,
"fullName": "Utah Hockey Club",
"teamCommonName": "Hockey Club",
"teamPlaceName": "Utah"
}
],
"total": 39
"total": 40
}
3 changes: 2 additions & 1 deletion nhlpy/data/teams_20232024.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
{ "id": "23", "abbreviation": "VAN", "name": "Vancouver Canucks" },
{ "id": "54", "abbreviation": "VGK", "name": "Vegas Golden Knights" },
{ "id": "15", "abbreviation": "WSH", "name": "Washington Capitals" },
{ "id": "52", "abbreviation": "WPG", "name": "Winnipeg Jets" }
{ "id": "52", "abbreviation": "WPG", "name": "Winnipeg Jets" },
{ "id": "40", "abbreviation": "UTA", "name": "Utah Hockey Club"}
]
}
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.7.1"
version = "2.8.0"
description = "NHL API (Updated for 2024/2025) and EDGE Stats. For standings, team stats, outcomes, player information. Contains each individual API endpoint as well as convience methods as well as pythonic query builder for more indepth EDGE stats."
authors = ["Corey Schaf <[email protected]>"]
readme = "README.md"
Expand Down
9 changes: 1 addition & 8 deletions tests/test_teams.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from unittest import mock


@mock.patch("httpx.Client.get")
def test_stats_summary(h_m, nhl_client):
nhl_client.teams.team_stats_summary()
h_m.assert_called_once()
assert h_m.call_args[1]["url"] == "https://api.nhle.com/stats/rest/en/team/summary"


@mock.patch("httpx.Client.get")
def test_roster(h_m, nhl_client):
nhl_client.teams.roster(team_abbr="BUF", season="20202021")
Expand All @@ -17,4 +10,4 @@ def test_roster(h_m, nhl_client):

def test_teams_info(nhl_client):
teams = nhl_client.teams.teams_info()
assert len(teams) == 32
assert len(teams) == 33
Loading