mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-13 06:34:45 -04:00

The album ID was the ID of the artist, not the album. Fixed now. The tests in this file now pass.
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
import logging
|
|
|
|
import pytest
|
|
from util import afor, arun
|
|
|
|
from streamrip.config import Config
|
|
from streamrip.client.downloadable import BasicDownloadable
|
|
from streamrip.exceptions import MissingCredentialsError
|
|
from streamrip.client.qobuz import QobuzClient
|
|
from fixtures.clients import qobuz_client
|
|
|
|
|
|
logger = logging.getLogger("streamrip")
|
|
|
|
|
|
@pytest.fixture()
|
|
def client(qobuz_client):
|
|
return qobuz_client
|
|
|
|
|
|
def test_client_raises_missing_credentials():
|
|
c = Config.defaults()
|
|
with pytest.raises(MissingCredentialsError):
|
|
arun(QobuzClient(c).login())
|
|
|
|
|
|
def test_client_get_metadata(client):
|
|
meta = arun(client.get_metadata("s9nzkwg2rh1nc", "album"))
|
|
assert meta["title"] == "I Killed Your Dog"
|
|
assert len(meta["tracks"]["items"]) == 16
|
|
assert meta["maximum_bit_depth"] == 24
|
|
|
|
|
|
def test_client_get_downloadable(client):
|
|
d = arun(client.get_downloadable("19512574", 3))
|
|
assert isinstance(d, BasicDownloadable)
|
|
assert d.extension == "flac"
|
|
assert isinstance(d.url, str)
|
|
assert "https://" in d.url
|
|
|
|
|
|
def test_client_search_limit(client):
|
|
res = client.search("album", "rumours", limit=5)
|
|
total = 0
|
|
for r in arun(res):
|
|
total += len(r["albums"]["items"])
|
|
assert total == 5
|
|
|
|
|
|
def test_client_search_no_limit(client):
|
|
# Setting no limit has become impossible because `limit: int` now
|
|
res = client.search("album", "rumours", limit=10000)
|
|
correct_total = 0
|
|
total = 0
|
|
for r in arun(res):
|
|
total += len(r["albums"]["items"])
|
|
correct_total = max(correct_total, r["albums"]["total"])
|
|
assert total == correct_total
|