How to use the fpl.models.player.Player function in fpl

To help you get started, we’ve selected a few fpl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amosbastian / fpl / tests / test_fpl.py View on Github external
async def test_player(self, loop, fpl):
        # test invalid ID
        with pytest.raises(ValueError):
            await fpl.get_player(-1)

        player = await fpl.get_player(1)
        assert isinstance(player, Player)

        player = await fpl.get_player(1, return_json=True)
        assert isinstance(player, dict)

        player_with_summary = await fpl.get_player(1, include_summary=True)

        assert isinstance(player_with_summary.fixtures, list)
github amosbastian / fpl / tests / test_fpl.py View on Github external
async def test_players(self, loop, fpl):
        players = await fpl.get_players()
        assert isinstance(players, list)
        assert isinstance(players[0], Player)

        players = await fpl.get_players(return_json=True)
        assert isinstance(players, list)
        assert isinstance(players[0], dict)

        players = await fpl.get_players([1, 2, 3])
        assert len(players) == 3

        players = await fpl.get_players([1, 2, 3], True)
        assert len(players) == 3
        assert isinstance(players[0].fixtures, list)
github amosbastian / fpl / fpl / fpl.py View on Github external
try:
            player = next(player for player in players.values()
                          if player["id"] == player_id)
        except StopIteration:
            raise ValueError(f"Player with ID {player_id} not found")

        if include_summary:
            player_summary = await self.get_player_summary(
                player["id"], return_json=True)
            player.update(player_summary)

        if return_json:
            return player

        return Player(player, self.session)
github amosbastian / fpl / fpl / models / team.py View on Github external
:type return_json: bool
        :rtype: list
        """
        team_players = getattr(self, "players", [])

        if not team_players:
            players = await fetch(self._session, API_URLS["static"])
            players = players["elements"]
            team_players = [player for player in players
                            if player["team"] == self.id]
            self.players = team_players

        if return_json:
            return team_players

        return [Player(player, self._session) for player in team_players]
github amosbastian / fpl / fpl / models / fixture.py View on Github external
def add_player(location, information):
    """Appends player to the location list."""
    player = Player(information["element"])
    goals = information["value"]
    location.append({"player": player, "goals": goals})