From 44d0c2c966a34e9eb97bb8c2cd1af630d3d72111 Mon Sep 17 00:00:00 2001 From: Hugo Date: Sun, 2 Jun 2019 22:54:03 +0300 Subject: [PATCH 1/2] user.getArtistTracks has now been removed from Last.fm and returns an error --- src/pylast/__init__.py | 3 +-- tests/test_album.py | 16 ---------------- tests/test_user.py | 11 +++++++++++ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 6cbea87..93c8c49 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -2260,11 +2260,10 @@ class User(_BaseObject, _Chartable): 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, including scrobble time. """ - # Not implemented: - # "Can be limited to specific timeranges, defaults to all time." warnings.warn( "User.get_artist_tracks is deprecated and will be removed in a future " diff --git a/tests/test_album.py b/tests/test_album.py index c1eb4a8..878e4e1 100755 --- a/tests/test_album.py +++ b/tests/test_album.py @@ -3,9 +3,6 @@ Integration (not unit) tests for pylast.py """ import unittest -import warnings - -import pytest import pylast @@ -42,19 +39,6 @@ class TestPyLastAlbum(TestPyLastWithLastFm): # Assert 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): # Arrange album = pylast.Album("Test Artist", "Test Album", self.network) diff --git a/tests/test_user.py b/tests/test_user.py index cf37c09..1154fdf 100755 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -461,6 +461,17 @@ class TestPyLastUser(TestPyLastWithLastFm): # Assert 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__": unittest.main(failfast=True) From c7b927d94cfb4aea93db19f6c545969cd150e145 Mon Sep 17 00:00:00 2001 From: Hugo Date: Mon, 3 Jun 2019 16:45:54 +0300 Subject: [PATCH 2/2] user.getArtistTracks has been removed from Last.fm --- tests/test_user.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/tests/test_user.py b/tests/test_user.py index 1154fdf..e648962 100755 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -182,20 +182,6 @@ class TestPyLastUser(TestPyLastWithLastFm): # Assert 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): # Arrange lastfm_user = self.network.get_authenticated_user()