Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def test_gameweeks(self, loop, fpl):
gameweeks = await fpl.get_gameweeks()
assert isinstance(gameweeks, list)
assert len(gameweeks) == 38
assert isinstance(gameweeks[0], Gameweek)
gameweeks = await fpl.get_gameweeks([1, 2, 3], return_json=True)
assert isinstance(gameweeks, list)
assert len(gameweeks) == 3
assert isinstance(gameweeks[0], dict)
async def test_gameweek(self, loop, fpl):
gameweek = await fpl.get_gameweek(20)
assert isinstance(gameweek, Gameweek)
assert gameweek.id == 20
assert not hasattr(gameweek, "elements")
gameweek = await fpl.get_gameweek(20, return_json=True)
assert isinstance(gameweek, dict)
assert gameweek["id"] == 20
assert "elements" not in gameweek.keys()
gameweek = await fpl.get_gameweek(1, include_live=True)
assert isinstance(gameweek, Gameweek)
assert hasattr(gameweek, "elements")
assert isinstance(gameweek.elements, dict)
gameweek = await fpl.get_gameweek(1, include_live=True,
return_json=True)
assert isinstance(gameweek, dict)
bonus_for_gameweek.extend(bonus["a"] + bonus["h"])
bonus_for_gameweek = {bonus["element"]: bonus["value"]
for bonus in bonus_for_gameweek}
for player_id, bonus_points in bonus_for_gameweek.items():
if live_gameweek["elements"][player_id]["stats"]["bonus"] == 0:
live_gameweek["elements"][player_id]["stats"]["bonus"] += bonus_points
live_gameweek["elements"][player_id]["stats"]["total_points"] += bonus_points
static_gameweek.update(live_gameweek)
if return_json:
return static_gameweek
return Gameweek(static_gameweek)