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_player_summaries(self, loop, fpl):
# test no specified IDs
player_summaries = await fpl.get_player_summaries([])
assert isinstance(player_summaries, list)
assert len(player_summaries) == 0
player_summaries = await fpl.get_player_summaries([1, 2, 3])
assert isinstance(player_summaries, list)
assert isinstance(player_summaries[0], PlayerSummary)
assert len(player_summaries) == 3
player_summaries = await fpl.get_player_summaries([1, 2, 3], True)
assert isinstance(player_summaries[0], dict)
async def test_player_summary(self, loop, fpl):
# test non positive id
with pytest.raises(AssertionError):
await fpl.get_player_summary(0)
player_summary = await fpl.get_player_summary(123)
assert isinstance(player_summary, PlayerSummary)
player_summary = await fpl.get_player_summary(123, True)
assert isinstance(player_summary, dict)
:param int player_id: A player's ID.
:param return_json: (optional) Boolean. If ``True`` returns a ``dict``,
if ``False`` returns a :class:`PlayerSummary` object. Defaults to
``False``.
:type return_json: bool
:rtype: :class:`PlayerSummary` or ``dict``
"""
assert int(player_id) > 0, "Player's ID must be a positive number"
url = API_URLS["player"].format(player_id)
player_summary = await fetch(self.session, url)
if return_json:
return player_summary
return PlayerSummary(player_summary)