fix import, argument order, afor->arun, album ID

The album ID was the ID of the artist, not the album. Fixed now.

The tests in this file now pass.
This commit is contained in:
draco 2023-12-26 23:55:30 +01:00
parent 5d34eda4b9
commit 267c48962e

View file

@ -7,6 +7,8 @@ from streamrip.config import Config
from streamrip.client.downloadable import BasicDownloadable from streamrip.client.downloadable import BasicDownloadable
from streamrip.exceptions import MissingCredentialsError from streamrip.exceptions import MissingCredentialsError
from streamrip.client.qobuz import QobuzClient from streamrip.client.qobuz import QobuzClient
from fixtures.clients import qobuz_client
logger = logging.getLogger("streamrip") logger = logging.getLogger("streamrip")
@ -23,7 +25,7 @@ def test_client_raises_missing_credentials():
def test_client_get_metadata(client): def test_client_get_metadata(client):
meta = arun(client.get_metadata("lzpf67e8f4h1a", "album")) meta = arun(client.get_metadata("s9nzkwg2rh1nc", "album"))
assert meta["title"] == "I Killed Your Dog" assert meta["title"] == "I Killed Your Dog"
assert len(meta["tracks"]["items"]) == 16 assert len(meta["tracks"]["items"]) == 16
assert meta["maximum_bit_depth"] == 24 assert meta["maximum_bit_depth"] == 24
@ -38,18 +40,19 @@ def test_client_get_downloadable(client):
def test_client_search_limit(client): def test_client_search_limit(client):
res = client.search("rumours", "album", limit=5) res = client.search("album", "rumours", limit=5)
total = 0 total = 0
for r in afor(res): for r in arun(res):
total += len(r["albums"]["items"]) total += len(r["albums"]["items"])
assert total == 5 assert total == 5
def test_client_search_no_limit(client): def test_client_search_no_limit(client):
res = client.search("rumours", "album", limit=None) # Setting no limit has become impossible because `limit: int` now
res = client.search("album", "rumours", limit=10000)
correct_total = 0 correct_total = 0
total = 0 total = 0
for r in afor(res): for r in arun(res):
total += len(r["albums"]["items"]) total += len(r["albums"]["items"])
correct_total = max(correct_total, r["albums"]["total"]) correct_total = max(correct_total, r["albums"]["total"])
assert total == correct_total assert total == correct_total