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
`SessionKeyGenerator.get_web_auth_session_key_username` ([#290])
### Deprecated
* `User.get_artist_tracks` ([#298])
## [3.0.0] - 2019-01-01
### Added
* 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
[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
[#298]: https://github.com/pylast/pylast/issues/298
[#290]: https://github.com/pylast/pylast/pull/290
[#265]: https://github.com/pylast/pylast/issues/265
[#273]: https://github.com/pylast/pylast/issues/273

View file

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

View file

@ -3,6 +3,7 @@
Integration (not unit) tests for pylast.py
"""
import unittest
import warnings
import pylast
@ -44,7 +45,9 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
lastfm_user = self.network.get_user(self.username)
# 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
self.assertTrue(hasattr(track, "album"))

View file

@ -4,6 +4,7 @@ Integration (not unit) tests for pylast.py
"""
import os
import unittest
import warnings
import pylast
@ -186,9 +187,11 @@ class TestPyLastUser(TestPyLastWithLastFm):
lastfm_user = self.network.get_authenticated_user()
# Act
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")
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)