summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-01-14 21:19:48 +0100
committerschneefux <schneefux+commit@schneefux.xyz>2017-01-14 21:19:48 +0100
commit814c7262ed1c9863ea6106840c217a69182eced3 (patch)
treea82a9baf1a34287080808b9404069633040bee06 /tests
parente3337188804e1521cc0a9ae72a172a71657c5f45 (diff)
downloadpython-gamelocker-814c7262ed1c9863ea6106840c217a69182eced3.tar.gz
python-gamelocker-814c7262ed1c9863ea6106840c217a69182eced3.zip
rewrite API to parse with xamoom-janus
Diffstat (limited to 'tests')
-rw-r--r--tests/gamelocker_test.py50
1 files changed, 19 insertions, 31 deletions
diff --git a/tests/gamelocker_test.py b/tests/gamelocker_test.py
index 9220d43..0b61d8f 100644
--- a/tests/gamelocker_test.py
+++ b/tests/gamelocker_test.py
@@ -11,43 +11,31 @@ class TestGamelocker:
def api(self):
return gamelocker.Gamelocker(self.apikey).vainglory()
- def test_utils(self):
- assert gamelocker.Utils().search_dict({"a": "b", "c": "d", "e": 2}, "e", 2) == True
- assert gamelocker.Utils().search_dict({"a": "b", "c": {"d":1, "e": 2}}, "e", 2) == True
- assert gamelocker.Utils().search_dict({"a": "b", "c": {"d":1, "e": 2}}, "f", 1) == False
-
def test_req(self, api):
with pytest.raises(requests.exceptions.HTTPError):
assert api._req("foobar")
-# with pytest.raises(AttributeError): # TODO write this test
-# pass
- assert api._req("status").raw["status"] == 200
- assert len(api._req("matches", {"page[limit]": 10}).raw["data"]) == 10
+ assert type(api._req("status")) is dict
+
+ assert "status" in api.status()
- def test_status(self, api):
- assert type(api.status()) is str
+ def test_map(self):
+ assert gamelocker.datatypes.modulemap()["match"] is gamelocker.datatypes.Match
- def test_matches(self, api):
- assert gamelocker.Matches(None, []).length == 0
- assert gamelocker.Matches(None, [None, None]).length == 2
+ def test_match(self, api):
+ match = api.match("91cf2ee4-d7d0-11e6-ad79-062445d3d668")
+ assert match.gameMode == "casual"
+ assert isinstance(match.rosters[0], gamelocker.datatypes.Roster)
+ assert isinstance(match.rosters[0].participants[0], gamelocker.datatypes.Participant)
+ assert isinstance(match.rosters[0].participants[0].player, gamelocker.datatypes.Player)
+ assert isinstance(match.rosters[0].participants[0].player.name, str)
matches = api.matches()
- assert type(matches) is gamelocker.Matches
- assert type(matches[0]) is gamelocker.Match
- assert type(matches[0].rosters[0]) is gamelocker.Roster
- assert type(matches[0].rosters[0].participants[0]) is gamelocker.Participant
- assert type(matches[0].rosters[0].participants[0].attributes["actor"]) is str
- assert type(matches[0].rosters[0].participants[0].player) is gamelocker.Player
- assert type(matches[0].rosters[0].participants[0].player.attributes["name"]) is str
+ assert len(matches) > 0
+ assert isinstance(matches[0], gamelocker.datatypes.Match)
+ assert matches[0].duration > 0
- def test_filter(self, api):
- assert api.matches().where("gameMode", "ranked").length > 0
- assert api.matches().where("gameMode", "foobar").length == 0
- assert api.matches(3).where("side", "left/blue").length == 3
- # in 3 games, there were 3 teams who were on the left side ;)
+ assert len(api.matches(limit=5)) == 5
- def test_pagination(self, api):
- assert api.matches(50).length <= 50
- assert api.matches(10).length <= 10
- assert api.matches(3).length == 3
- api.matches(10, offset=30)
+ def test_player(self, api):
+ assert api.player("6abb30de-7cb8-11e4-8bd3-06eb725f8a76").name == "boombastic04"
+ assert "lossStreak" in api.player("6abb30de-7cb8-11e4-8bd3-06eb725f8a76").stats