How to use the fpl.models.fixture.Fixture 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_fixture.py View on Github external
def test_init():
        fixture = Fixture(fixture_data)
        for k, v in fixture_data.items():
            if k != 'stats':
                assert getattr(fixture, k) == v
github amosbastian / fpl / tests / test_fpl.py View on Github external
async def test_fixtures(self, loop, fpl):
        fixtures = await fpl.get_fixtures()
        assert isinstance(fixtures, list)
        assert isinstance(fixtures[0], Fixture)

        fixtures = await fpl.get_fixtures(return_json=True)
        assert isinstance(fixtures[0], dict)
github amosbastian / fpl / tests / test_fpl.py View on Github external
async def test_fixture(self, loop, fpl):
        # test fixture with unknown id
        with pytest.raises(ValueError):
            await fpl.get_fixture(0)

        fixture = await fpl.get_fixture(6)
        assert isinstance(fixture, Fixture)

        fixture = await fpl.get_fixture(6, return_json=True)
        assert isinstance(fixture, dict)
github amosbastian / fpl / fpl / fpl.py View on Github external
gameweek_fixtures = await fetch(
            self.session,
            API_URLS["gameweek_fixtures"].format(fixture_gameweek))

        try:
            fixture = next(fixture for fixture in gameweek_fixtures
                           if fixture["id"] == fixture_id)
        except StopIteration:
            raise ValueError(
                f"Fixture with ID {fixture_id} not found in gameweek fixtures")

        if return_json:
            return fixture

        return Fixture(fixture)
github amosbastian / fpl / fpl / fpl.py View on Github external
:type return_json: bool
        :rtype: list
        """
        gameweeks = range(1, 39)
        tasks = [asyncio.ensure_future(
                 fetch(self.session,
                       API_URLS["gameweek_fixtures"].format(gameweek)))
                 for gameweek in gameweeks]

        gameweek_fixtures = await asyncio.gather(*tasks)
        fixtures = list(itertools.chain(*gameweek_fixtures))

        if return_json:
            return fixtures

        return [Fixture(fixture) for fixture in fixtures]