diff --git a/tests/conftest.py b/tests/conftest.py index f7d680a..c264e92 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,9 +3,9 @@ import pytest_asyncio -@pytest_asyncio.fixture(scope="session") +@pytest_asyncio.fixture(scope="session", autouse=True) def event_loop(): - loop = asyncio.new_event_loop() + loop = asyncio.get_event_loop_policy().get_event_loop() yield loop - loop.run_until_complete(asyncio.sleep(1)) + loop.run_until_complete(asyncio.sleep(0.025)) loop.close() diff --git a/tests/test_21_issue.py b/tests/test_21_issue.py index a3c727f..bc13463 100644 --- a/tests/test_21_issue.py +++ b/tests/test_21_issue.py @@ -1,3 +1,4 @@ +import pytest import pytest_asyncio from shazamio import Serialize @@ -250,6 +251,7 @@ def song_response(): yield response +@pytest.mark.asyncio async def test_recognize_song_bug(song_response: bytes): serialize_out = Serialize.full_track(data=song_response) assert serialize_out.matches[0].channel is None diff --git a/tests/test_about_artist.py b/tests/test_about_artist.py new file mode 100644 index 0000000..5ca9054 --- /dev/null +++ b/tests/test_about_artist.py @@ -0,0 +1,33 @@ +import pytest + +from shazamio import Serialize +from shazamio import Shazam +from shazamio.schemas.artists import ArtistQuery +from shazamio.schemas.enums import ArtistExtend +from shazamio.schemas.enums import ArtistView + + +@pytest.mark.asyncio +async def test_about_artist(): + shazam = Shazam(language="ES") + artist_id = 659860538 + + about_artist = await shazam.artist_about( + artist_id, + query=ArtistQuery( + views=[ + ArtistView.FULL_ALBUMS, + ArtistView.LATEST_RELEASE, + ], + extend=[ + ArtistExtend.ARTIST_BIO, + ArtistExtend.BORN_OF_FORMED, + ArtistExtend.EDITORIAL_ARTWORK, + ArtistExtend.ORIGIN, + ], + ), + ) + + serialized = Serialize.artist_v2(about_artist) + assert serialized.data[0].attributes.name == "Markul" + assert "Hip-hop/Rap" in serialized.data[0].attributes.genre_names diff --git a/tests/test_peak_spreading_numpy.py b/tests/test_peak_spreading_numpy.py index bc46e7c..ce39530 100644 --- a/tests/test_peak_spreading_numpy.py +++ b/tests/test_peak_spreading_numpy.py @@ -1,3 +1,4 @@ +import pytest from pydub import AudioSegment from typing import List @@ -35,6 +36,7 @@ def do_peak_spreading_non_numpy(self): pass +@pytest.mark.asyncio async def test_do_peak_spreading_numpy(): audio = AudioSegment.from_file(file="examples/data/dora.ogg") diff --git a/tests/test_recognize.py b/tests/test_recognize.py index e5a24f5..23e8fdc 100644 --- a/tests/test_recognize.py +++ b/tests/test_recognize.py @@ -1,3 +1,4 @@ +import pytest import pytest_asyncio from pydub import AudioSegment from io import BytesIO @@ -11,6 +12,7 @@ async def song_bytes(): yield await get_file_bytes(file="examples/data/dora.ogg") +@pytest.mark.asyncio async def test_recognize_song_file(): shazam = Shazam() out = await shazam.recognize_song(data="examples/data/dora.ogg") @@ -19,6 +21,7 @@ async def test_recognize_song_file(): assert out["track"]["key"] == "549679333" +@pytest.mark.asyncio async def test_recognize_song_bytes(song_bytes: bytes): shazam = Shazam() out = await shazam.recognize_song(data=song_bytes) @@ -27,6 +30,7 @@ async def test_recognize_song_bytes(song_bytes: bytes): assert out["track"]["key"] == "549679333" +@pytest.mark.asyncio async def test_recognize_song_too_short(): short_audio_segment = AudioSegment.from_file( file=BytesIO(b"0" * 126),