Skip to content

Commit

Permalink
Test *NotFound
Browse files Browse the repository at this point in the history
  • Loading branch information
tehkillerbee committed Feb 13, 2024
1 parent e907654 commit 37e4ede
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
20 changes: 14 additions & 6 deletions tests/test_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import tidalapi
from tidalapi.album import Album
from tidalapi.exceptions import MetadataNotAvailable, ObjectNotFound

from .cover import verify_image_cover, verify_video_cover

Expand Down Expand Up @@ -110,12 +111,19 @@ def test_default_image_used_if_no_cover_art(mocker):
def test_similar(session):
album = session.album(108043414)
for alb in album.similar():
if alb.id == 64522277:
# Album with no similar albums should trigger AttributeError (response: 404)
with pytest.raises(AttributeError):
alb.similar()
else:
assert isinstance(alb.similar()[0], tidalapi.Album)
assert isinstance(alb.similar()[0], tidalapi.Album)
# if alb.id == 64522277:
# # Album with no similar albums should trigger MetadataNotAvailable (response: 404)
# # TODO Find an album with no similar albums related to it
# with pytest.raises(MetadataNotAvailable):
# alb.similar()
# else:
# assert isinstance(alb.similar()[0], tidalapi.Album)


def test_album_not_found(session):
with pytest.raises(ObjectNotFound):
session.album(123456789)


def test_review(session):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import requests

import tidalapi
from tidalapi.exceptions import ObjectNotFound

from .cover import verify_image_cover

Expand All @@ -42,6 +43,11 @@ def test_artist(session):
assert requests.get(artist.image(160)).status_code == 200


def test_artist_not_found(session):
with pytest.raises(ObjectNotFound):
session.artist(123456789)


def test_get_albums(session):
artist = session.artist(16147)
albums = [
Expand Down
5 changes: 3 additions & 2 deletions tests/test_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from dateutil import tz

import tidalapi
from tidalapi.exceptions import MetadataNotAvailable

from .cover import verify_image_resolution, verify_video_resolution

Expand Down Expand Up @@ -75,8 +76,8 @@ def test_lyrics(session):

def test_no_lyrics(session):
track = session.track(17626400)
# Tracks with no lyrics should trigger AttributeError (response: 404)
with pytest.raises(AttributeError):
# Tracks with no lyrics should trigger MetadataNotAvailable (response: 404)
with pytest.raises(MetadataNotAvailable):
track.lyrics()


Expand Down
6 changes: 6 additions & 0 deletions tests/test_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dateutil import tz

import tidalapi
from tidalapi.exceptions import ObjectNotFound

from .cover import verify_image_cover, verify_image_resolution

Expand Down Expand Up @@ -78,6 +79,11 @@ def test_updated_playlist(session):
assert creator.name == "user"


def test_playlist_not_found(session):
with pytest.raises(ObjectNotFound):
session.playlist("12345678")


def test_video_playlist(session):
playlist = session.playlist("aa3611ff-5b25-4bbe-8ce4-36c678c3438f")
assert playlist.id == "aa3611ff-5b25-4bbe-8ce4-36c678c3438f"
Expand Down

0 comments on commit 37e4ede

Please sign in to comment.