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()
league = H2HLeague(h2h_league_data, session)
assert league._session == session
for k, v in h2h_league_data.items():
assert getattr(league, k) == v
await session.close()
async def test_h2h_league(self, loop, fpl):
await fpl.login()
h2h_league = await fpl.get_h2h_league(902521)
assert isinstance(h2h_league, H2HLeague)
h2h_league = await fpl.get_h2h_league(902521, True)
assert isinstance(h2h_league, dict)
:param return_json: (optional) Boolean. If ``True`` returns a ``dict``,
if ``False`` returns a :class:`H2HLeague` object. Defaults to
``False``.
:type return_json: bool
:rtype: :class:`H2HLeague` or ``dict``
"""
if not logged_in(self.session):
raise Exception("User must be logged in.")
url = API_URLS["league_h2h"].format(league_id)
league = await fetch(self.session, url)
if return_json:
return league
return H2HLeague(league, session=self.session)