diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-01-18 19:28:50 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-01-18 19:28:50 +0100 |
| commit | 8a8989b7a1f4768c07d37625c915d493f05c31b4 (patch) | |
| tree | 727f821da02fff1f23b271f0a47977a7ab3a58c1 | |
| parent | a09d5dba095314f4cb76f5480f6328a19b2668e8 (diff) | |
| download | python-gamelocker-8a8989b7a1f4768c07d37625c915d493f05c31b4.tar.gz python-gamelocker-8a8989b7a1f4768c07d37625c915d493f05c31b4.zip | |
fix player filtering and offsets
| -rw-r--r-- | gamelocker/api.py | 6 | ||||
| -rw-r--r-- | tests/gamelocker_test.py | 42 |
2 files changed, 24 insertions, 24 deletions
diff --git a/gamelocker/api.py b/gamelocker/api.py index 112ec8c..3f0388f 100644 --- a/gamelocker/api.py +++ b/gamelocker/api.py @@ -176,9 +176,9 @@ class Gamelocker(object): if sort: # TODO make this nice and usable params["sort"] = sort if player: - params["filter[playerName]"] = player + params["filter[playerNames]"] = player if team: - params["filter[teamName]"] = team + params["filter[teamNames]"] = team if createdAtStart: if isinstance(createdAtStart, datetime.datetime): createdAtStart = createdAtStart.isoformat() @@ -192,7 +192,7 @@ class Gamelocker(object): matches = [] for batch in range(0, limit, max_limit): params["page[limit]"] = min(limit, max_limit) - params["page[offset]"] = max_limit+offset + params["page[offset]"] = batch+offset matches += self._get("matches", params=params) limit -= max_limit diff --git a/tests/gamelocker_test.py b/tests/gamelocker_test.py index 34facb6..36d4ef0 100644 --- a/tests/gamelocker_test.py +++ b/tests/gamelocker_test.py @@ -87,27 +87,27 @@ class TestGamelocker: for match in matches: assert fromiso(end) >= fromiso(match.createdAt) >= fromiso(start) -# nick = "MMotooks123" -# matches = api.matches(limit=5, player=nick) -# for match in matches: -# success = False -# for roster in match.rosters: -# for participant in roster.participants: -# if participant.player.name == nick: -# success = True -# break -# assert success -# -# team = "HALO" -# matches = api.matches(limit=5, team=team) -# for match in matches: -# success = False -# for roster in match.rosters: -# if roster.team: -# if roster.team.name == team: -# success = True -# break -# assert success + nick = "MMotooks123" + matches = api.matches(limit=5, player=nick) + for match in matches: + success = False + for roster in match.rosters: + for participant in roster.participants: + if participant.player.name == nick: + success = True + break + assert success + + team = "HALO" + matches = api.matches(limit=5, team=team) + for match in matches: + success = False + for roster in match.rosters: + if roster.team: + if roster.team.name == team: + success = True + break + assert success def test_player(self, api): assert api.player("6abb30de-7cb8-11e4-8bd3-06eb725f8a76").name == "boombastic04" |
