-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
43 - Updates NHLClient to use https.Client on requests. (#44)
Allows NHLClient to be configured with additional configuration options: timeout, ssl_verify, follow_redirects. These are configurable at the instantiation point. Updates tests to now mock httxp.Client.get instead of httpx.get. Updates README.md with new configuration options available
- Loading branch information
Showing
11 changed files
with
57 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.3.4" | ||
__version__ = "2.4.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
class ClientConfig: | ||
def __init__(self, verbose: bool = False) -> None: | ||
def __init__( | ||
self, verbose: bool = False, timeout: int = 10, ssl_verify: bool = True, follow_redirects: bool = True | ||
) -> None: | ||
self.verbose = verbose | ||
self.timeout = timeout | ||
self.ssl_verify = ssl_verify | ||
self.follow_redirects = follow_redirects | ||
|
||
self.api_web_base_url = "https://api-web.nhle.com" | ||
self.api_base_url = "https://api.nhle.com" | ||
self.api_web_api_ver = "/v1/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" | |
|
||
[tool.poetry] | ||
name = "nhl-api-py" | ||
version = "2.3.4" | ||
version = "2.4.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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
from unittest import mock | ||
|
||
|
||
@mock.patch("httpx.get") | ||
@mock.patch("httpx.Client.get") | ||
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") | ||
@mock.patch("httpx.Client.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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters