How to use the fpl.models.team.Team 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_team(self, loop, fpl):
        # test team id out of valid range
        with pytest.raises(AssertionError):
            await fpl.get_team(0)
        with pytest.raises(AssertionError):
            await fpl.get_team(21)

        team = await fpl.get_team(1)
        assert isinstance(team, Team)

        team = await fpl.get_team(1, True)
        assert isinstance(team, dict)
github amosbastian / fpl / tests / test_fpl.py View on Github external
async def test_teams(self, loop, fpl):
        teams = await fpl.get_teams()
        assert isinstance(teams, list)
        assert len(teams) == 20
        assert isinstance(teams[0], Team)

        teams = await fpl.get_teams(return_json=True)
        assert isinstance(teams, list)
        assert len(teams) == 20
        assert isinstance(teams[0], dict)

        teams = await fpl.get_teams(team_ids=[1, 2, 3])
        assert isinstance(teams, list)
        assert len(teams) == 3
        assert isinstance(teams[0], Team)
        assert [team.id for team in teams] == [1, 2, 3]
github amosbastian / fpl / fpl / fpl.py View on Github external
Defaults to ``False``.
        :type return_json: bool
        :rtype: list
        """
        teams = getattr(self, "teams")

        if team_ids:
            team_ids = set(team_ids)
            teams = [team for team in teams.values() if team["id"] in team_ids]
        else:
            teams = [team for team in teams.values()]

        if return_json:
            return teams

        return [Team(team_information, self.session)
                for team_information in teams]
github amosbastian / fpl / fpl / fpl.py View on Github external
16 - Southampton
            17 - Spurs
            18 - Watford
            19 - West Ham
            20 - Wolves
        """
        assert 0 < int(
            team_id) < 21, "Team ID must be a number between 1 and 20."
        teams = getattr(self, "teams")
        team = next(team for team in teams.values()
                    if team["id"] == int(team_id))

        if return_json:
            return team

        return Team(team, self.session)