Deprecate User.get_artist_tracks as Last.fm will remove it soon

This commit is contained in:
Hugo 2019-02-26 22:53:31 +02:00
parent 69b54e8c45
commit 9d125506e5
4 changed files with 25 additions and 6 deletions

View file

@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Extract username from session via new * Extract username from session via new
`SessionKeyGenerator.get_web_auth_session_key_username` ([#290]) `SessionKeyGenerator.get_web_auth_session_key_username` ([#290])
### Deprecated
* `User.get_artist_tracks` ([#298])
## [3.0.0] - 2019-01-01 ## [3.0.0] - 2019-01-01
### Added ### Added
* This changelog file ([#273]) * This changelog file ([#273])
@ -31,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[Unreleased]: https://github.com/pylast/pylast/compare/v3.0.0...HEAD [Unreleased]: https://github.com/pylast/pylast/compare/v3.0.0...HEAD
[3.0.0]: https://github.com/pylast/pylast/compare/2.4.0...3.0.0 [3.0.0]: https://github.com/pylast/pylast/compare/2.4.0...3.0.0
[2.4.0]: https://github.com/pylast/pylast/compare/2.3.0...2.4.0 [2.4.0]: https://github.com/pylast/pylast/compare/2.3.0...2.4.0
[#298]: https://github.com/pylast/pylast/issues/298
[#290]: https://github.com/pylast/pylast/pull/290 [#290]: https://github.com/pylast/pylast/pull/290
[#265]: https://github.com/pylast/pylast/issues/265 [#265]: https://github.com/pylast/pylast/issues/265
[#273]: https://github.com/pylast/pylast/issues/273 [#273]: https://github.com/pylast/pylast/issues/273

View file

@ -20,18 +20,19 @@
# #
# https://github.com/pylast/pylast # https://github.com/pylast/pylast
from xml.dom import minidom, Node
import collections import collections
import hashlib import hashlib
import html.entities
import logging import logging
import shelve import shelve
import ssl import ssl
import sys import sys
import tempfile import tempfile
import time import time
import warnings
import xml.dom import xml.dom
import html.entities
from http.client import HTTPSConnection from http.client import HTTPSConnection
from xml.dom import Node, minidom
from . import version from . import version
@ -2236,6 +2237,13 @@ class User(_BaseObject, _Chartable):
# Not implemented: # Not implemented:
# "Can be limited to specific timeranges, defaults to all time." # "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 "
"version: https://github.com/pylast/pylast/issues/298",
DeprecationWarning,
stacklevel=2,
)
params = self._get_params() params = self._get_params()
params["artist"] = artist params["artist"] = artist

View file

@ -3,6 +3,7 @@
Integration (not unit) tests for pylast.py Integration (not unit) tests for pylast.py
""" """
import unittest import unittest
import warnings
import pylast import pylast
@ -44,7 +45,9 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
lastfm_user = self.network.get_user(self.username) lastfm_user = self.network.get_user(self.username)
# Act # Act
track = lastfm_user.get_artist_tracks(artist="Test Artist")[0] with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
track = lastfm_user.get_artist_tracks(artist="Test Artist")[0]
# Assert # Assert
self.assertTrue(hasattr(track, "album")) self.assertTrue(hasattr(track, "album"))

View file

@ -4,6 +4,7 @@ Integration (not unit) tests for pylast.py
""" """
import os import os
import unittest import unittest
import warnings
import pylast import pylast
@ -186,9 +187,11 @@ class TestPyLastUser(TestPyLastWithLastFm):
lastfm_user = self.network.get_authenticated_user() lastfm_user = self.network.get_authenticated_user()
# Act # Act
result1 = lastfm_user.get_artist_tracks("Test Artist", cacheable=False) with warnings.catch_warnings():
result2 = lastfm_user.get_artist_tracks("Test Artist", cacheable=True) warnings.filterwarnings("ignore", category=DeprecationWarning)
result3 = lastfm_user.get_artist_tracks("Test Artist") 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 # Assert
self.helper_validate_results(result1, result2, result3) self.helper_validate_results(result1, result2, result3)