Update user.get_artist_tracks tests (#305)
Update user.get_artist_tracks tests
This commit is contained in:
commit
46e4c0ec4c
|
@ -2260,11 +2260,10 @@ class User(_BaseObject, _Chartable):
|
||||||
|
|
||||||
def get_artist_tracks(self, artist, cacheable=False):
|
def get_artist_tracks(self, artist, cacheable=False):
|
||||||
"""
|
"""
|
||||||
|
Deprecated by Last.fm.
|
||||||
Get a list of tracks by a given artist scrobbled by this user,
|
Get a list of tracks by a given artist scrobbled by this user,
|
||||||
including scrobble time.
|
including scrobble time.
|
||||||
"""
|
"""
|
||||||
# Not implemented:
|
|
||||||
# "Can be limited to specific timeranges, defaults to all time."
|
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"User.get_artist_tracks is deprecated and will be removed in a future "
|
"User.get_artist_tracks is deprecated and will be removed in a future "
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
Integration (not unit) tests for pylast.py
|
Integration (not unit) tests for pylast.py
|
||||||
"""
|
"""
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
import pylast
|
import pylast
|
||||||
|
|
||||||
|
@ -42,19 +39,6 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
self.assertTrue(hasattr(track, "album"))
|
self.assertTrue(hasattr(track, "album"))
|
||||||
|
|
||||||
@pytest.mark.skip(reason="Last.fm is removing from API")
|
|
||||||
def test_album_in_artist_tracks(self):
|
|
||||||
# Arrange
|
|
||||||
lastfm_user = self.network.get_user(self.username)
|
|
||||||
|
|
||||||
# Act
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
||||||
track = lastfm_user.get_artist_tracks(artist="Test Artist")[0]
|
|
||||||
|
|
||||||
# Assert
|
|
||||||
self.assertTrue(hasattr(track, "album"))
|
|
||||||
|
|
||||||
def test_album_wiki_content(self):
|
def test_album_wiki_content(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
album = pylast.Album("Test Artist", "Test Album", self.network)
|
album = pylast.Album("Test Artist", "Test Album", self.network)
|
||||||
|
|
|
@ -182,20 +182,6 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
self.assertEqual(lastfm_user, loaded_user)
|
self.assertEqual(lastfm_user, loaded_user)
|
||||||
|
|
||||||
def test_cacheable_user_artist_tracks(self):
|
|
||||||
# Arrange
|
|
||||||
lastfm_user = self.network.get_authenticated_user()
|
|
||||||
|
|
||||||
# Act
|
|
||||||
with warnings.catch_warnings():
|
|
||||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
|
||||||
result1 = lastfm_user.get_artist_tracks("Test Artist", cacheable=False)
|
|
||||||
result2 = lastfm_user.get_artist_tracks("Test Artist", cacheable=True)
|
|
||||||
result3 = lastfm_user.get_artist_tracks("Test Artist")
|
|
||||||
|
|
||||||
# Assert
|
|
||||||
self.helper_validate_results(result1, result2, result3)
|
|
||||||
|
|
||||||
def test_cacheable_user(self):
|
def test_cacheable_user(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
lastfm_user = self.network.get_authenticated_user()
|
lastfm_user = self.network.get_authenticated_user()
|
||||||
|
@ -461,6 +447,17 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
self.helper_validate_results(result1, result2, result3)
|
self.helper_validate_results(result1, result2, result3)
|
||||||
|
|
||||||
|
def test_get_artist_tracks_deprecated(self):
|
||||||
|
# Arrange
|
||||||
|
lastfm_user = self.network.get_user(self.username)
|
||||||
|
|
||||||
|
# Act / Assert
|
||||||
|
with warnings.catch_warnings(), self.assertRaisesRegex(
|
||||||
|
pylast.WSError, "Deprecated - This type of request is no longer supported"
|
||||||
|
):
|
||||||
|
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||||
|
lastfm_user.get_artist_tracks(artist="Test Artist")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main(failfast=True)
|
unittest.main(failfast=True)
|
||||||
|
|
Loading…
Reference in a new issue