Skip to content

Commit 6ed6f88

Browse files
authored
Merge pull request #45 from dotX12/dev-issues-35-about_artists
Fix and added new tests
2 parents 29eeb44 + 84bc1e7 commit 6ed6f88

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import pytest_asyncio
44

55

6-
@pytest_asyncio.fixture(scope="session")
6+
@pytest_asyncio.fixture(scope="session", autouse=True)
77
def event_loop():
8-
loop = asyncio.new_event_loop()
8+
loop = asyncio.get_event_loop_policy().get_event_loop()
99
yield loop
10-
loop.run_until_complete(asyncio.sleep(1))
10+
loop.run_until_complete(asyncio.sleep(0.025))
1111
loop.close()

tests/test_21_issue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
import pytest_asyncio
23

34
from shazamio import Serialize
@@ -250,6 +251,7 @@ def song_response():
250251
yield response
251252

252253

254+
@pytest.mark.asyncio
253255
async def test_recognize_song_bug(song_response: bytes):
254256
serialize_out = Serialize.full_track(data=song_response)
255257
assert serialize_out.matches[0].channel is None

tests/test_about_artist.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import pytest
2+
3+
from shazamio import Serialize
4+
from shazamio import Shazam
5+
from shazamio.schemas.artists import ArtistQuery
6+
from shazamio.schemas.enums import ArtistExtend
7+
from shazamio.schemas.enums import ArtistView
8+
9+
10+
@pytest.mark.asyncio
11+
async def test_about_artist():
12+
shazam = Shazam(language="ES")
13+
artist_id = 659860538
14+
15+
about_artist = await shazam.artist_about(
16+
artist_id,
17+
query=ArtistQuery(
18+
views=[
19+
ArtistView.FULL_ALBUMS,
20+
ArtistView.LATEST_RELEASE,
21+
],
22+
extend=[
23+
ArtistExtend.ARTIST_BIO,
24+
ArtistExtend.BORN_OF_FORMED,
25+
ArtistExtend.EDITORIAL_ARTWORK,
26+
ArtistExtend.ORIGIN,
27+
],
28+
),
29+
)
30+
31+
serialized = Serialize.artist_v2(about_artist)
32+
assert serialized.data[0].attributes.name == "Markul"
33+
assert "Hip-hop/Rap" in serialized.data[0].attributes.genre_names

tests/test_peak_spreading_numpy.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from pydub import AudioSegment
23
from typing import List
34

@@ -35,6 +36,7 @@ def do_peak_spreading_non_numpy(self):
3536
pass
3637

3738

39+
@pytest.mark.asyncio
3840
async def test_do_peak_spreading_numpy():
3941
audio = AudioSegment.from_file(file="examples/data/dora.ogg")
4042

tests/test_recognize.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
import pytest_asyncio
23
from pydub import AudioSegment
34
from io import BytesIO
@@ -11,6 +12,7 @@ async def song_bytes():
1112
yield await get_file_bytes(file="examples/data/dora.ogg")
1213

1314

15+
@pytest.mark.asyncio
1416
async def test_recognize_song_file():
1517
shazam = Shazam()
1618
out = await shazam.recognize_song(data="examples/data/dora.ogg")
@@ -19,6 +21,7 @@ async def test_recognize_song_file():
1921
assert out["track"]["key"] == "549679333"
2022

2123

24+
@pytest.mark.asyncio
2225
async def test_recognize_song_bytes(song_bytes: bytes):
2326
shazam = Shazam()
2427
out = await shazam.recognize_song(data=song_bytes)
@@ -27,6 +30,7 @@ async def test_recognize_song_bytes(song_bytes: bytes):
2730
assert out["track"]["key"] == "549679333"
2831

2932

33+
@pytest.mark.asyncio
3034
async def test_recognize_song_too_short():
3135
short_audio_segment = AudioSegment.from_file(
3236
file=BytesIO(b"0" * 126),

0 commit comments

Comments
 (0)