-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Fixtures for testing.""" | ||
|
||
from collections.abc import AsyncGenerator | ||
|
||
from aiohttp import ClientSession | ||
from aioresponses import aioresponses | ||
import pytest | ||
|
||
from aiolyric.client import LyricClient | ||
from aiolyric.const import AUTH_URL, BASE_URL, TOKEN_URL | ||
|
||
from . import RESPONSE_JSON_BASIC | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def mock_aioresponse(): | ||
"""Return a client session.""" | ||
with aioresponses() as mocker: | ||
mocker.get( | ||
AUTH_URL, | ||
payload=RESPONSE_JSON_BASIC, | ||
status=200, | ||
repeat=True, | ||
) | ||
mocker.get( | ||
TOKEN_URL, | ||
payload=RESPONSE_JSON_BASIC, | ||
status=200, | ||
repeat=True, | ||
) | ||
mocker.get( | ||
BASE_URL, | ||
payload=RESPONSE_JSON_BASIC, | ||
status=200, | ||
repeat=True, | ||
) | ||
|
||
yield mocker | ||
|
||
|
||
@pytest.fixture | ||
async def lyric_client() -> AsyncGenerator[LyricClient, None]: | ||
"""Return a LyricClient.""" | ||
async with ClientSession() as session: | ||
yield LyricClient(session=session) |