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_init(self, loop):
session = aiohttp.ClientSession()
classic_league = ClassicLeague(classic_league_data, session)
assert classic_league._session is session
for k, v in classic_league_data.items():
assert getattr(classic_league, k) == v
await session.close()
async def test_classic_league(self, loop, fpl):
await fpl.login()
classic_league = await fpl.get_classic_league(173226)
assert isinstance(classic_league, ClassicLeague)
classic_league = await fpl.get_classic_league(173226, return_json=True)
assert isinstance(classic_league, dict)
:param return_json: (optional) Boolean. If ``True`` returns a ``dict``,
if ``False`` returns a :class:`ClassicLeague` object. Defaults to
``False``.
:type return_json: bool
:rtype: :class:`ClassicLeague` or ``dict``
"""
if not logged_in(self.session):
raise Exception("User must be logged in.")
url = API_URLS["league_classic"].format(league_id)
league = await fetch(self.session, url)
if return_json:
return league
return ClassicLeague(league, session=self.session)