Skip to content

Commit

Permalink
Adds tests for Playoffs (#51)
Browse files Browse the repository at this point in the history
Adds tests and version bump.

- Renames internal module from Playoff to Playoffs.
- Adds pytest around the playoff endpoints.
- Version bump to 2.6.0
  • Loading branch information
coreyjs committed Apr 26, 2024
1 parent 47e8cab commit ed48db7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 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.5.1"
__version__ = "2.6.0"
7 changes: 3 additions & 4 deletions nhlpy/api/playoff.py → nhlpy/api/playoffs.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from nhlpy.http_client import HttpClient


class Playoff:
class Playoffs:
def __init__(self, http_client: HttpClient):
self.client = http_client

def carousel(self, season: str) -> dict:
"""
Get the list of all series games. Currently only
shows Round 1 games
Get the list of all series games up to the current round.
:param season: the current season ex. "20232024"
Expand All @@ -23,7 +22,7 @@ def schedule(self, season: str, series: str) -> dict:
"""
Returns the schedule for a specified series.
:param season: the the season you wish to see the schedule of
:param season: the season you wish to see the schedule of
:param series: the series (a-h) for Round 1
example:
Expand Down
4 changes: 2 additions & 2 deletions nhlpy/nhl_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nhlpy.api import teams, standings, schedule, game_center, stats, misc, playoff
from nhlpy.api import teams, standings, schedule, game_center, stats, misc, playoffs
from nhlpy.http_client import HttpClient
from nhlpy.config import ClientConfig

Expand Down Expand Up @@ -35,4 +35,4 @@ def __init__(
self.game_center = game_center.GameCenter(http_client=self._http_client)
self.stats = stats.Stats(http_client=self._http_client)
self.misc = misc.Misc(http_client=self._http_client)
self.playoff = playoff.Playoff(http_client=self._http_client)
self.playoffs = playoffs.Playoffs(http_client=self._http_client)
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.5.1"
version = "2.6.0"
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 <[email protected]>"]
readme = "README.md"
Expand Down
22 changes: 22 additions & 0 deletions tests/test_playoffs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from unittest import mock


@mock.patch("httpx.Client.get")
def test_carousel(h_m, nhl_client):
nhl_client.playoffs.carousel(season="20232024")
h_m.assert_called_once()
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/playoff-series/carousel/20232024"


@mock.patch("httpx.Client.get")
def test_schedule(h_m, nhl_client):
nhl_client.playoffs.schedule(season="20232024", series="a")
h_m.assert_called_once()
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/schedule/playoff-series/20232024/a"


@mock.patch("httpx.Client.get")
def test_bracket(h_m, nhl_client):
nhl_client.playoffs.bracket(year="2024")
h_m.assert_called_once()
assert h_m.call_args[1]["url"] == "https://api-web.nhle.com/v1/playoff-bracket/2024"

0 comments on commit ed48db7

Please sign in to comment.