Skip to content

Commit

Permalink
Add status v4 stuff to docs; bump version (#182)
Browse files Browse the repository at this point in the history
* Add status v4 stuff to docs; bump version
  • Loading branch information
pseudonym117 authored Aug 11, 2021
1 parent 97f2d8d commit 16659b3
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 8 deletions.
50 changes: 46 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
RiotWatcher v3.1.2
==================
RiotWatcher
===========

|pypi| |docs| |coverage| |lgmt| |black|

Check for full (read: slightly better) documentation `here <http://riot-watcher.readthedocs.io/en/latest/>`__!

RiotWatcher is a thin wrapper on top of the `Riot Games API for League
of Legends <https://developer.riotgames.com/>`__. All public methods as
of 7/4/2021 are supported in full.
of 8/11/2021 are supported in full.

RiotWatcher by default supports a naive rate limiter. This rate limiter will
try to stop you from making too many requests, and in a single threaded test
Expand Down Expand Up @@ -87,7 +87,7 @@ raised as HTTPError exceptions from the Requests library.
MatchApiV5
----------

As of 7/4/2021, both the v4 and v5 versions of the Match API are supported by Riot. As such, RiotWatcher provides a
As of 8/11/2021, both the v4 and v5 versions of the Match API are supported by Riot. As such, RiotWatcher provides a
method to use both. By default, the v4 API will be used for backwards compatibility.

To use the v5 API by default, use the following to initialize your LolWatcher instance:
Expand All @@ -103,6 +103,7 @@ To use the v5 API by default, use the following to initialize your LolWatcher in
To explicitly use v4 or v5 during the deprecation period, you can use the following properties:


.. code:: python
from riotwatcher import LolWatcher
Expand All @@ -120,6 +121,43 @@ and the change will happen with a minor version increase. If you desire seamless
properies.


StatusApiV4
-----------

As of 8/11/2021 (and from the looks of it, indefinitely), both v3 and v4 versions of the LolStatus API are supported by Riot.
As such, RiotWatcher provides a method to use both. By default, the v3 API will be used for backwards compatibility.

To use the v4 API by default, use the following to initialize your LolWatcher instance:

.. code:: python
from riotwatcher import LolWatcher
lol_watcher = LolWatcher('<your-api-key>', default_status_v4=True)
# example call
matchlist = lol_watcher.lol_status.platform_data('na1')
To explicitly use v4 or v5 during the deprecation period, you can use the following properties:


.. code:: python
from riotwatcher import LolWatcher
lol_watcher = LolWatcher('<your-api-key>')
# use v4 explicitly
matchlist = lol_watcher.lol_status_v4.platform_data('na1')
# use v3 explicitly
old_matchlist = lol_watcher.lol_status_v3.shard_data('na1')
Note: this will not be supported after v3 is completely deprecated! Both lol_status_v3 and lol_status_v4 properties will be removed,
and the change will happen with a minor version increase. If you desire seamless backwards compatibility, do not use these
properies.


Use with kernel
---------------

Expand Down Expand Up @@ -149,6 +187,10 @@ Rate limiter has some race conditions when used concurrently.

Changelog
---------
v3.1.4 - 8/11/2021
~~~~~~~~~~~~~~~~~~
Add LolStatus-V4 API. Didnt realize this existed until now.

v3.1.3 - 8/5/2021
~~~~~~~~~~~~~~~~~
Add query "queue" and "type" params for match v5 api
Expand Down
8 changes: 8 additions & 0 deletions docs/riotwatcher/LeagueOfLegends/LolStatusApiV4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
LolStatusApiV4
==============

.. py:currentmodule:: riotwatcher
.. autoclass:: riotwatcher._apis.league_of_legends.LolStatusApiV4
:members:
:undoc-members:
1 change: 1 addition & 0 deletions docs/riotwatcher/LeagueOfLegends/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ All APIs
DataDragonApi.rst
LeagueApiV4.rst
LolStatusApiV3.rst
LolStatusApiV4.rst
MatchApiV4.rst
MatchApiV5.rst
SpectatorApiV4.rst
Expand Down
22 changes: 21 additions & 1 deletion src/riotwatcher/LolWatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ def __init__(
self._third_party_code = ThirdPartyCodeApiV4(self._base_api)

self._match = self._match_v5 if default_match_v5 else self._match_v4
self._lol_status = self._lol_status_v4 if default_status_v4 else self._lol_status_v3
self._lol_status = (
self._lol_status_v4 if default_status_v4 else self._lol_status_v3
)
# todo: tournament-stub
# todo: tournament

Expand Down Expand Up @@ -149,6 +151,24 @@ def lol_status(self) -> Union[LolStatusApiV3, LolStatusApiV4]:
"""
return self._lol_status

@property
def lol_status_v3(self) -> LolStatusApiV3:
"""
Interface to the LoLStatus Endpoint
:rtype: league_of_legends.LolStatusApiV3
"""
return self._lol_status_v3

@property
def lol_status_v4(self) -> LolStatusApiV4:
"""
Interface to the LoLStatus Endpoint
:rtype: league_of_legends.LolStatusApiV4
"""
return self._lol_status_v4

@property
def match(self) -> Union[MatchApiV4, MatchApiV5]:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/riotwatcher/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "3.1.3"
__version__ = "3.1.4"
__author__ = "pseudonym117"
__title__ = "RiotWatcher"
2 changes: 1 addition & 1 deletion tests/integration/league_of_legends/test_LolStatusApiV3.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
class TestStatusApiV3:
def test_shard_data(self, lol_context, region):
actual_response = lol_context.watcher.lol_status.shard_data(region)
actual_response = lol_context.watcher.lol_status_v3.shard_data(region)

lol_context.verify_api_call(
region, "/lol/status/v3/shard-data", {}, actual_response
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/league_of_legends/test_LolStatusV4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest


@pytest.mark.lol
@pytest.mark.integration
@pytest.mark.parametrize(
"region",
[
"br1",
"eun1",
"euw1",
"jp1",
"kr",
"la1",
"la2",
"na",
"na1",
"oc1",
"tr1",
"ru",
"pbe1",
],
)
class TestStatusApiV4:
def test_platform_data(self, lol_context, region):
actual_response = lol_context.watcher.lol_status_v4.platform_data(region)

lol_context.verify_api_call(
region, "/lol/status/v4/platform-data", {}, actual_response
)
19 changes: 18 additions & 1 deletion tests/test_LolWatcher.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import pytest

from riotwatcher import LolWatcher
from riotwatcher._apis.league_of_legends import MatchApiV4, MatchApiV5
from riotwatcher._apis.league_of_legends import (
MatchApiV4,
MatchApiV5,
LolStatusApiV3,
LolStatusApiV4,
)


@pytest.mark.lol
Expand Down Expand Up @@ -31,3 +36,15 @@ def test_uses_match_v4_when_false(self):
def test_uses_match_v5_when_true(self):
watcher = LolWatcher(api_key="RGAPI-this-is-a-fake", default_match_v5=True)
assert isinstance(watcher.match, MatchApiV5)

def test_defaults_status_v3(self):
watcher = LolWatcher(api_key="RGAPI-this-is-a-fake")
assert isinstance(watcher.lol_status, LolStatusApiV3)

def test_uses_status_v3_when_false(self):
watcher = LolWatcher(api_key="RGAPI-this-is-a-fake", default_status_v4=False)
assert isinstance(watcher.lol_status, LolStatusApiV3)

def test_uses_status_v4_when_true(self):
watcher = LolWatcher(api_key="RGAPI-this-is-a-fake", default_status_v4=True)
assert isinstance(watcher.lol_status, LolStatusApiV4)

0 comments on commit 16659b3

Please sign in to comment.