def __init__(self, album_item): self.id = album_item.get("id") self.title = album_item.get("title") self.tracks_count = album_item.get("tracks_count") self.released_at = album_item.get("released_at") self.artist = qobuz.Artist(album_item["artist"]) self._tracks = None
def test_album_init(app): album = qobuz.Album(album_get_json) assert album.id == album_get_json["id"] assert album.title == album_get_json["title"] assert album.tracks_count == album_get_json["tracks_count"] assert album.released_at == album_get_json["released_at"] assert album.artist == qobuz.Artist(album_get_json["artist"])
def test_artist_album_content(app, response_all_albums): artist = qobuz.Artist(artist_get_albums_json) albums = artist.get_all_albums() assert albums[0].id == "0886443927087" assert albums[ 0].title == u"Random Access Memories (Édition Studio Masters)" assert albums[0].tracks_count == 13 assert albums[0].released_at == 1368741600
def test_artist_init(app): artist_item = artist_search_json["artists"]["items"][0] artist = qobuz.Artist(artist_item) assert artist.id == artist_item["id"] assert artist.name == artist_item["name"] assert artist.picture == artist_item["picture"] assert artist.slug == artist_item["slug"] assert artist.albums_count == artist_item["albums_count"]
def test_track_artist_lookup(app, track, artist): with responses.RequestsMock() as response_mock: response_mock.add( responses.GET, url=qobuz.api.API_URL + "artist/get", json=artist_get_albums_json, status=200, match_querystring=False, ) assert track.artist == qobuz.Artist(artist_get_albums_json)
def test_artist_album_artist(app, response_all_albums): artist = qobuz.Artist(artist_get_albums_json) albums = artist.get_all_albums() for a in albums: assert isinstance(a.artist, qobuz.Artist) assert albums[0].artist.name == "Daft Punk" assert albums[0].artist.id == 36819 assert albums[0].artist.picture is None assert albums[0].artist.slug == "daft-punk" assert albums[0].artist.albums_count == 52
def test_artist_from_id(app): artist_item = artist_search_json["artists"]["items"][0] with responses.RequestsMock() as response_mock: response_mock.add( responses.GET, url=get_url(artist_item["id"]), json=artist_item, status=200, match_querystring=True, ) artist_from_id = qobuz.Artist.from_id(artist_item["id"]) assert artist_from_id == qobuz.Artist(artist_item)
def test_artist_albums_type(app, response_all_albums): artist = qobuz.Artist(artist_get_albums_json) for a in artist.get_all_albums(): assert isinstance(a, qobuz.Album)
def test_artist_albums_len(app, response_all_albums): artist = qobuz.Artist(artist_get_albums_json) assert len(artist.get_all_albums()) == 25
def artist(): artist_item = artist_search_json["artists"]["items"][0] return qobuz.Artist(artist_item)