-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2010aee
commit a6ba4c9
Showing
14 changed files
with
161 additions
and
11 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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MatchApi | ||
======== | ||
|
||
.. py:currentmodule:: riotwatcher | ||
.. autoclass:: riotwatcher._apis.legends_of_runeterra.MatchApi | ||
:members: | ||
:undoc-members: |
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 |
---|---|---|
|
@@ -12,8 +12,7 @@ All APIs | |
-------- | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
RankedApi.rst | ||
|
||
:maxdepth: 1 | ||
|
||
MatchApi.rst | ||
RankedApi.rst |
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 @@ | ||
__version__ = "3.1.0" | ||
__version__ = "3.1.1" | ||
__author__ = "pseudonym117" | ||
__title__ = "RiotWatcher" |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from .. import BaseApi, NamedEndpoint | ||
from .urls import MatchApiUrls | ||
|
||
|
||
class MatchApi(NamedEndpoint): | ||
""" | ||
This class wraps the LoR-Match-V1 Api calls provided by the Riot API. | ||
See https://developer.riotgames.com/apis#lor-match-v1 for more detailed | ||
information | ||
""" | ||
|
||
def __init__(self, base_api: BaseApi): | ||
""" | ||
Initialize a new MatchApi which uses the provided base_api | ||
:param BaseApi base_api: the root API object to use for making all requests. | ||
""" | ||
super().__init__(base_api, self.__class__.__name__) | ||
|
||
def by_puuid(self, region: str, puuid: str): | ||
""" | ||
Get a list of match ids by PUUID. | ||
:returns: List[string] | ||
""" | ||
return self._request_endpoint( | ||
self.by_puuid.__name__, region, MatchApiUrls.by_puuid, puuid=puuid | ||
) | ||
|
||
def by_id(self, region: str, match_id: str): | ||
""" | ||
Get match by id. | ||
:returns: MatchDto | ||
""" | ||
return self._request_endpoint( | ||
self.by_id.__name__, region, MatchApiUrls.by_id, match_id=match_id | ||
) |
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 +1,2 @@ | ||
from .MatchApi import MatchApi | ||
from .RankedApi import RankedApi |
11 changes: 11 additions & 0 deletions
11
src/riotwatcher/_apis/legends_of_runeterra/urls/MatchApiUrls.py
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from .LorEndpoint import LorEndpoint | ||
|
||
|
||
class MatchEndpoint(LorEndpoint): | ||
def __init__(self, url: str, **kwargs): | ||
super().__init__(f"/match/v1{url}", **kwargs) | ||
|
||
|
||
class MatchApiUrls: | ||
by_puuid = MatchEndpoint("/matches/by-puuid/{puuid}/ids") | ||
by_id = MatchEndpoint("/matches/{match_id}") |
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 +1,2 @@ | ||
from .MatchApiUrls import MatchApiUrls | ||
from .RankedApiUrls import RankedApiUrls |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
|
||
from riotwatcher._apis.legends_of_runeterra import MatchApi | ||
|
||
|
||
@pytest.fixture(params=["match_id_001122"]) | ||
def match_id(request): | ||
return request.param | ||
|
||
|
||
@pytest.mark.lor | ||
@pytest.mark.unit | ||
class TestMatchApi: | ||
def test_by_puuid(self, region, puuid): | ||
mock_base_api = MagicMock() | ||
expected_return = object() | ||
mock_base_api.raw_request.return_value = expected_return | ||
|
||
match = MatchApi(mock_base_api) | ||
|
||
ret = match.by_puuid(region, puuid) | ||
|
||
mock_base_api.raw_request.assert_called_once_with( | ||
MatchApi.__name__, | ||
match.by_puuid.__name__, | ||
region, | ||
f"https://{region}.api.riotgames.com/lor/match/v1/matches/by-puuid/{puuid}/ids", | ||
{}, | ||
) | ||
|
||
assert ret is expected_return | ||
|
||
def test_by_id(self, region, match_id): | ||
mock_base_api = MagicMock() | ||
expected_return = object() | ||
mock_base_api.raw_request.return_value = expected_return | ||
|
||
match = MatchApi(mock_base_api) | ||
|
||
ret = match.by_id(region, match_id) | ||
|
||
mock_base_api.raw_request.assert_called_once_with( | ||
MatchApi.__name__, | ||
match.by_id.__name__, | ||
region, | ||
f"https://{region}.api.riotgames.com/lor/match/v1/matches/{match_id}", | ||
{}, | ||
) | ||
|
||
assert ret is expected_return |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(params=["EUROPE", "ASIA", "AMERICAS"]) | ||
def region(request): | ||
return request.param |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture(params=["533c8122-f17b-44c1-9254-81a9288a9a6b"]) | ||
def match_id(request): | ||
return request.param | ||
|
||
|
||
@pytest.mark.lor | ||
@pytest.mark.integration | ||
class TestRankedApi: | ||
def test_by_puuid(self, lor_context, region, puuid): | ||
actual_response = lor_context.watcher.match.by_puuid(region, puuid) | ||
|
||
lor_context.verify_api_call( | ||
region, f"/lor/match/v1/matches/by-puuid/{puuid}/ids", {}, actual_response, | ||
) | ||
|
||
def test_by_id(self, lor_context, region, match_id): | ||
actual_response = lor_context.watcher.match.by_id(region, match_id) | ||
|
||
lor_context.verify_api_call( | ||
region, f"/lor/match/v1/matches/{match_id}", {}, actual_response, | ||
) |
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