From 1a46ad2cb37caeaa036130de0df0124b4d320429 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 16 Jun 2015 23:20:36 +0300 Subject: [PATCH 01/18] Replace broken pypip.in badges with shields.io [CI skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d95d09d..f936d12 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pyLast ====== -[![Build Status](https://travis-ci.org/pylast/pylast.svg?branch=develop)](https://travis-ci.org/pylast/pylast) [![PyPI version](https://pypip.in/version/pylast/badge.svg)](https://pypi.python.org/pypi/pylast/) [![PyPI downloads](https://pypip.in/download/pylast/badge.svg)](https://pypi.python.org/pypi/pylast/) [![Coverage Status](https://coveralls.io/repos/pylast/pylast/badge.png?branch=develop)](https://coveralls.io/r/pylast/pylast?branch=develop) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/pylast/pylast/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/pylast/pylast/?branch=develop) [![Code Health](https://landscape.io/github/pylast/pylast/develop/landscape.svg)](https://landscape.io/github/hugovk/pylast/develop) +[![Build Status](https://travis-ci.org/pylast/pylast.svg?branch=develop)](https://travis-ci.org/pylast/pylast) [![PyPI version](https://img.shields.io/pypi/v/pylast.svg)](https://pypi.python.org/pypi/pylast/) [![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypi.python.org/pypi/pylast/) [![Coverage Status](https://coveralls.io/repos/pylast/pylast/badge.png?branch=develop)](https://coveralls.io/r/pylast/pylast?branch=develop) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/pylast/pylast/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/pylast/pylast/?branch=develop) [![Code Health](https://landscape.io/github/pylast/pylast/develop/landscape.svg)](https://landscape.io/github/hugovk/pylast/develop) A Python interface to [Last.fm](http://www.last.fm/) and other api-compatible websites such as [Libre.fm](http://libre.fm/). From 941dd0123bdeb951f5322dc6161adce04a0fdc28 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 16 Jun 2015 23:21:42 +0300 Subject: [PATCH 02/18] Remove useless Scrutinizer badge [CI skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f936d12..323dec4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ pyLast ====== -[![Build Status](https://travis-ci.org/pylast/pylast.svg?branch=develop)](https://travis-ci.org/pylast/pylast) [![PyPI version](https://img.shields.io/pypi/v/pylast.svg)](https://pypi.python.org/pypi/pylast/) [![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypi.python.org/pypi/pylast/) [![Coverage Status](https://coveralls.io/repos/pylast/pylast/badge.png?branch=develop)](https://coveralls.io/r/pylast/pylast?branch=develop) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/pylast/pylast/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/pylast/pylast/?branch=develop) [![Code Health](https://landscape.io/github/pylast/pylast/develop/landscape.svg)](https://landscape.io/github/hugovk/pylast/develop) +[![Build Status](https://travis-ci.org/pylast/pylast.svg?branch=develop)](https://travis-ci.org/pylast/pylast) [![PyPI version](https://img.shields.io/pypi/v/pylast.svg)](https://pypi.python.org/pypi/pylast/) [![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypi.python.org/pypi/pylast/) [![Coverage Status](https://coveralls.io/repos/pylast/pylast/badge.png?branch=develop)](https://coveralls.io/r/pylast/pylast?branch=develop) [![Code Health](https://landscape.io/github/pylast/pylast/develop/landscape.svg)](https://landscape.io/github/hugovk/pylast/develop) A Python interface to [Last.fm](http://www.last.fm/) and other api-compatible websites such as [Libre.fm](http://libre.fm/). From c8f8b60ec75a4cef479ad02806b743051c6ee935 Mon Sep 17 00:00:00 2001 From: brtkrbzhnv Date: Thu, 25 Jun 2015 21:43:12 +0200 Subject: [PATCH 03/18] Support for User.GetPersonalTags Added functions User.get_tagged_albums, ..._tracks and ..._artists to support User.GetPersonalTags. --- pylast/__init__.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 50d40c7..7f25b27 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -32,7 +32,7 @@ import warnings import re import six -__version__ = '1.2.1' +__version__ = '1.2.2' __author__ = 'Amr Hassan, hugovk' __copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2015 hugovk" __license__ = "apache2" @@ -3505,6 +3505,43 @@ class User(_BaseObject, _Chartable): return doc.getElementsByTagName( "registered")[0].getAttribute("unixtime") + def get_tagged_albums(self, tag, limit=None, cacheable=True): + """Returns the albums tagged by a user.""" + + params = self._get_params() + params['tag'] = tag + params['taggingtype'] = 'album' + if limit: + params['limit'] = limit + + doc = self._request(self.ws_prefix + '.getpersonaltags', cacheable, params) + + return _extract_top_albums(doc, self.network) + + def get_tagged_artists(self, tag, limit=None): + """Returns the albums artists tagged by a user.""" + + params = self._get_params() + params['tag'] = tag + params['taggingtype'] = 'artist' + if limit: + params["limit"] = limit + + doc = self._request(self.ws_prefix + '.getpersonaltags', True, params) + + return _extract_top_artists(doc, self.network) + + def get_tagged_tracks(self, tag, limit=None, cacheable=True): + """Returns the tracks tagged by a user.""" + + params = self._get_params() + params['tag'] = tag + params['taggingtype'] = 'track' + if limit: + params['limit'] = limit + + return self._get_things("getpersonaltags", "track", Track, params, cacheable) + def get_top_albums( self, period=PERIOD_OVERALL, limit=None, cacheable=True): """Returns the top albums played by a user. From 658ed7a102667b07c9b49c254cddf7ad396c632d Mon Sep 17 00:00:00 2001 From: brtkrbzhnv Date: Thu, 25 Jun 2015 21:57:33 +0200 Subject: [PATCH 04/18] Cleanup of User.GetPersonalTags stuff --- pylast/__init__.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 7f25b27..efd8c24 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -3516,7 +3516,7 @@ class User(_BaseObject, _Chartable): doc = self._request(self.ws_prefix + '.getpersonaltags', cacheable, params) - return _extract_top_albums(doc, self.network) + return _extract_albums(doc, self.network) def get_tagged_artists(self, tag, limit=None): """Returns the albums artists tagged by a user.""" @@ -3529,7 +3529,7 @@ class User(_BaseObject, _Chartable): doc = self._request(self.ws_prefix + '.getpersonaltags', True, params) - return _extract_top_artists(doc, self.network) + return _extract_artists(doc, self.network) def get_tagged_tracks(self, tag, limit=None, cacheable=True): """Returns the tracks tagged by a user.""" @@ -3540,7 +3540,7 @@ class User(_BaseObject, _Chartable): if limit: params['limit'] = limit - return self._get_things("getpersonaltags", "track", Track, params, cacheable) + return _extract_tracks(doc, self.network) def get_top_albums( self, period=PERIOD_OVERALL, limit=None, cacheable=True): @@ -4123,7 +4123,30 @@ def _extract_top_albums(doc, network): return seq +def _extract_artists(doc, network): + seq = [] + for node in doc.getElementsByTagName("artist"): + seq.append(Artist(_extract(node, "name"), network)) + return seq + +def _extract_albums(doc, network): + seq = [] + for node in doc.getElementsByTagName("album"): + name = _extract(node, "name") + artist = _extract(node, "name", 1) + seq.append(Album(artist, name, network)) + return seq + +def _extract_tracks(doc, network): + seq = [] + for node in doc.getElementsByTagName("track"): + name = _extract(node, "name") + artist = _extract(node, "name", 1) + seq.append(Track(artist, name, network)) + return seq + + def _extract_events_from_doc(doc, network): events = [] for node in doc.getElementsByTagName("event"): From 4379e28c19d24b8d7beb1dd27755688224b8fe4f Mon Sep 17 00:00:00 2001 From: brtkrbzhnv Date: Fri, 26 Jun 2015 01:35:51 +0200 Subject: [PATCH 05/18] Fixed broken comment --- pylast/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index efd8c24..05b7de8 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -3730,7 +3730,7 @@ class AuthenticatedUser(User): def get_recommended_artists(self, limit=50, cacheable=False): """ - Returns a sequence of Event objects + Returns a sequence of Artist objects if limit==None it will return all """ From 8b321dfe748cb9e565d45f895fef28f4a92dab08 Mon Sep 17 00:00:00 2001 From: brtkrbzhnv Date: Sat, 27 Jun 2015 00:11:08 +0200 Subject: [PATCH 06/18] Added User.GetPersonalTags test cases --- tests/test_pylast.py | 46 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 1980e7a..664b118 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1040,7 +1040,13 @@ class TestPyLast(unittest.TestCase): self.assertIsInstance(things, list) self.assertIsInstance(things[0], pylast.TopItem) self.assertIsInstance(things[0].item, expected_type) - + + def helper_only_one_thing_in_list(self, things, expected_type): + # Assert + self.assertEqual(len(things), 1) + self.assertIsInstance(things, list) + self.assertIsInstance(things[0], expected_type) + def helper_two_different_things_in_top_list(self, things, expected_type): # Assert self.assertEqual(len(things), 2) @@ -1399,7 +1405,45 @@ class TestPyLast(unittest.TestCase): # Assert self.helper_only_one_thing_in_top_list(albums, pylast.Album) + + def test_user_tagged_artists(self): + # Arrange + lastfm_user = self.network.get_user(self.username) + tags = ["artisttagola"] + artist = self.network.get_artist("Test Artist") + artist.add_tags(tags) + + # Act + artists = lastfm_user.get_tagged_artists('artisttagola', limit=1) + + # Assert + self.helper_only_one_thing_in_list(artists, pylast.Artist) + def test_user_tagged_albums(self): + # Arrange + lastfm_user = self.network.get_user(self.username) + tags = ["albumtagola"] + album = self.network.get_album("Test Artist", "Test Album") + album.add_tags(tags) + + # Act + albums = lastfm_user.get_tagged_albums('albumtagola', limit=1) + + # Assert + self.helper_only_one_thing_in_list(albums, pylast.Album) + + def test_user_tagged_tracks(self): + # Arrange + lastfm_user = self.network.get_user(self.username) + tags = ["tracktagola"] + track = self.network.get_track("Test Artist", "Test Title") + track.add_tags(tags) + # Act + tracks = lastfm_user.get_tagged_tracks('tracktagola', limit=1) + + # Assert + self.helper_only_one_thing_in_list(tracks, pylast.Track) + def test_caching(self): # Arrange user = self.network.get_user("RJ") From aa5f00bbd67821705089f16f18351f3f319c51d0 Mon Sep 17 00:00:00 2001 From: brtkrbzhnv Date: Sat, 27 Jun 2015 00:11:40 +0200 Subject: [PATCH 07/18] User.GetPersonalTags bug fix get_tagged_tracks crashed --- pylast/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 05b7de8..98888f0 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -3513,9 +3513,7 @@ class User(_BaseObject, _Chartable): params['taggingtype'] = 'album' if limit: params['limit'] = limit - doc = self._request(self.ws_prefix + '.getpersonaltags', cacheable, params) - return _extract_albums(doc, self.network) def get_tagged_artists(self, tag, limit=None): @@ -3526,9 +3524,7 @@ class User(_BaseObject, _Chartable): params['taggingtype'] = 'artist' if limit: params["limit"] = limit - doc = self._request(self.ws_prefix + '.getpersonaltags', True, params) - return _extract_artists(doc, self.network) def get_tagged_tracks(self, tag, limit=None, cacheable=True): @@ -3539,7 +3535,7 @@ class User(_BaseObject, _Chartable): params['taggingtype'] = 'track' if limit: params['limit'] = limit - + doc = self._request(self.ws_prefix + '.getpersonaltags', True, params) return _extract_tracks(doc, self.network) def get_top_albums( From 51b0f3b11a47e0363716501a691116a24833f358 Mon Sep 17 00:00:00 2001 From: brtkrbzhnv Date: Sun, 28 Jun 2015 11:17:13 +0200 Subject: [PATCH 08/18] Fixed broken comment --- pylast/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 98888f0..aea4880 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -3517,7 +3517,7 @@ class User(_BaseObject, _Chartable): return _extract_albums(doc, self.network) def get_tagged_artists(self, tag, limit=None): - """Returns the albums artists tagged by a user.""" + """Returns the artists tagged by a user.""" params = self._get_params() params['tag'] = tag @@ -4461,4 +4461,4 @@ class Scrobbler(object): if remainder: self.scrobble_many(remainder) -# End of file +# End of file \ No newline at end of file From 71d59a17cac78d7b197d3e6b893b3934f80340c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neto?= Date: Wed, 1 Jul 2015 16:57:44 -0300 Subject: [PATCH 09/18] Add suppport for artist.getCorrection --- pylast/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pylast/__init__.py b/pylast/__init__.py index 50d40c7..5cc1507 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1928,6 +1928,12 @@ class Artist(_BaseObject, _Taggable): return self.name + def get_correction(self): + """Returns the corrected artist name.""" + + return _extract( + self._request(self.ws_prefix + ".getCorrection"), "name") + def get_cover_image(self, size=COVER_MEGA): """ Returns a uri to the cover image From db9bc4f216b4fddcea44863d445979b350d13ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neto?= Date: Wed, 1 Jul 2015 17:00:48 -0300 Subject: [PATCH 10/18] Add suppport for track.getCorrection --- pylast/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pylast/__init__.py b/pylast/__init__.py index 5cc1507..4313496 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -2952,6 +2952,12 @@ class Track(_Opus): def __init__(self, artist, title, network, username=None): super(Track, self).__init__(artist, title, network, "track", username) + + def get_correction(self): + """Returns the corrected track name.""" + + return _extract( + self._request(self.ws_prefix + ".getCorrection"), "name") def get_duration(self): """Returns the track duration.""" From 6b58f43c01599c65e81ddb0d910179689662a2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neto?= Date: Wed, 1 Jul 2015 17:04:01 -0300 Subject: [PATCH 11/18] Add test case for Artist.get_correction() --- tests/test_pylast.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 1980e7a..c388ef9 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1907,7 +1907,16 @@ class TestPyLast(unittest.TestCase): self.assertEqual(len(tracks), 1) self.assertEqual(str(tracks[0].track.artist), "Johnny Cash") self.assertEqual(str(tracks[0].track.title), "Ring of Fire") - + + def test_artist_get_correction(self): + # Arrange + artist = pylast.Artist("guns and roses", self.network) + + # Act + corrected_artist_name = artist.get_correction() + + # Assert + self.assertEqual(corrected_artist_name, "Guns N' Roses") if __name__ == '__main__': unittest.main(failfast=True) From 5f18619333011ebc4fe970d1e8f9b8d4cd983291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neto?= Date: Wed, 1 Jul 2015 17:04:43 -0300 Subject: [PATCH 12/18] Add test case for Track.get_correction() --- tests/test_pylast.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index c388ef9..1f3ae40 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1917,6 +1917,16 @@ class TestPyLast(unittest.TestCase): # Assert self.assertEqual(corrected_artist_name, "Guns N' Roses") + + def test_track_get_correction(self): + # Arrange + track = pylast.Track("Guns N' Roses", "mrbrownstone", self.network) + + # Act + corrected_track_name = track.get_correction() + + # Assert + self.assertEqual(corrected_track_name, "Mr. Brownstone") if __name__ == '__main__': unittest.main(failfast=True) From 2aaddbd81b31119966a3f19cb40e771b9efcefcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neto?= Date: Thu, 9 Jul 2015 16:56:09 -0300 Subject: [PATCH 13/18] pep8 compliance --- pylast/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 4313496..f593667 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -1930,7 +1930,7 @@ class Artist(_BaseObject, _Taggable): def get_correction(self): """Returns the corrected artist name.""" - + return _extract( self._request(self.ws_prefix + ".getCorrection"), "name") @@ -2952,12 +2952,12 @@ class Track(_Opus): def __init__(self, artist, title, network, username=None): super(Track, self).__init__(artist, title, network, "track", username) - + def get_correction(self): """Returns the corrected track name.""" - + return _extract( - self._request(self.ws_prefix + ".getCorrection"), "name") + self._request(self.ws_prefix + ".getCorrection"), "name") def get_duration(self): """Returns the track duration.""" From 2f72ec827060da8989c6dae6365ce3f61daf44f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Neto?= Date: Thu, 9 Jul 2015 17:02:53 -0300 Subject: [PATCH 14/18] pep8 compliance --- tests/test_pylast.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 1f3ae40..25a9596 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1907,24 +1907,24 @@ class TestPyLast(unittest.TestCase): self.assertEqual(len(tracks), 1) self.assertEqual(str(tracks[0].track.artist), "Johnny Cash") self.assertEqual(str(tracks[0].track.title), "Ring of Fire") - + def test_artist_get_correction(self): # Arrange artist = pylast.Artist("guns and roses", self.network) - + # Act corrected_artist_name = artist.get_correction() - + # Assert self.assertEqual(corrected_artist_name, "Guns N' Roses") - + def test_track_get_correction(self): # Arrange track = pylast.Track("Guns N' Roses", "mrbrownstone", self.network) - + # Act corrected_track_name = track.get_correction() - + # Assert self.assertEqual(corrected_track_name, "Mr. Brownstone") From 3240a54e323eaf82dd1b1b78b5b54c0ca860d94b Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 24 Jul 2015 11:01:34 +0300 Subject: [PATCH 15/18] flake8 --- pylast/__init__.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index aea4880..253013b 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -3513,7 +3513,8 @@ class User(_BaseObject, _Chartable): params['taggingtype'] = 'album' if limit: params['limit'] = limit - doc = self._request(self.ws_prefix + '.getpersonaltags', cacheable, params) + doc = self._request(self.ws_prefix + '.getpersonaltags', cacheable, + params) return _extract_albums(doc, self.network) def get_tagged_artists(self, tag, limit=None): @@ -3526,7 +3527,7 @@ class User(_BaseObject, _Chartable): params["limit"] = limit doc = self._request(self.ws_prefix + '.getpersonaltags', True, params) return _extract_artists(doc, self.network) - + def get_tagged_tracks(self, tag, limit=None, cacheable=True): """Returns the tracks tagged by a user.""" @@ -4119,6 +4120,7 @@ def _extract_top_albums(doc, network): return seq + def _extract_artists(doc, network): seq = [] for node in doc.getElementsByTagName("artist"): @@ -4134,6 +4136,7 @@ def _extract_albums(doc, network): seq.append(Album(artist, name, network)) return seq + def _extract_tracks(doc, network): seq = [] for node in doc.getElementsByTagName("track"): @@ -4141,8 +4144,8 @@ def _extract_tracks(doc, network): artist = _extract(node, "name", 1) seq.append(Track(artist, name, network)) return seq - - + + def _extract_events_from_doc(doc, network): events = [] for node in doc.getElementsByTagName("event"): @@ -4461,4 +4464,4 @@ class Scrobbler(object): if remainder: self.scrobble_many(remainder) -# End of file \ No newline at end of file +# End of file From c421fd5cbd5e09d64dbbaaaba9c8863138171be5 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 24 Jul 2015 11:22:39 +0300 Subject: [PATCH 16/18] flake8 --- tests/test_pylast.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 664b118..7deb4db 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -1040,13 +1040,13 @@ class TestPyLast(unittest.TestCase): self.assertIsInstance(things, list) self.assertIsInstance(things[0], pylast.TopItem) self.assertIsInstance(things[0].item, expected_type) - + def helper_only_one_thing_in_list(self, things, expected_type): # Assert self.assertEqual(len(things), 1) self.assertIsInstance(things, list) self.assertIsInstance(things[0], expected_type) - + def helper_two_different_things_in_top_list(self, things, expected_type): # Assert self.assertEqual(len(things), 2) @@ -1405,17 +1405,17 @@ class TestPyLast(unittest.TestCase): # Assert self.helper_only_one_thing_in_top_list(albums, pylast.Album) - + def test_user_tagged_artists(self): # Arrange lastfm_user = self.network.get_user(self.username) tags = ["artisttagola"] artist = self.network.get_artist("Test Artist") artist.add_tags(tags) - + # Act artists = lastfm_user.get_tagged_artists('artisttagola', limit=1) - + # Assert self.helper_only_one_thing_in_list(artists, pylast.Artist) @@ -1425,10 +1425,10 @@ class TestPyLast(unittest.TestCase): tags = ["albumtagola"] album = self.network.get_album("Test Artist", "Test Album") album.add_tags(tags) - + # Act albums = lastfm_user.get_tagged_albums('albumtagola', limit=1) - + # Assert self.helper_only_one_thing_in_list(albums, pylast.Album) @@ -1440,10 +1440,10 @@ class TestPyLast(unittest.TestCase): track.add_tags(tags) # Act tracks = lastfm_user.get_tagged_tracks('tracktagola', limit=1) - + # Assert self.helper_only_one_thing_in_list(tracks, pylast.Track) - + def test_caching(self): # Arrange user = self.network.get_user("RJ") From 6264b4fecc27271af847f44c92e3eb2512c65e83 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 24 Jul 2015 11:26:36 +0300 Subject: [PATCH 17/18] get_tagged_tracks: Use cacheable param --- pylast/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index 253013b..6ba0eb7 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -3536,7 +3536,8 @@ class User(_BaseObject, _Chartable): params['taggingtype'] = 'track' if limit: params['limit'] = limit - doc = self._request(self.ws_prefix + '.getpersonaltags', True, params) + doc = self._request(self.ws_prefix + '.getpersonaltags', cacheable, + params) return _extract_tracks(doc, self.network) def get_top_albums( From dae6a276ea0404095d4814f3fff475abc11d2889 Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 3 Aug 2015 13:54:21 +0300 Subject: [PATCH 18/18] Let Tox use these env vars --- tox.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tox.ini b/tox.ini index ec0e215..b5dd199 100644 --- a/tox.ini +++ b/tox.ini @@ -4,6 +4,11 @@ recreate = False [testenv] downloadcache = {homedir}/.pipcache +setenv = + PYLAST_USERNAME={env:PYLAST_USERNAME:} + PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:} + PYLAST_API_KEY={env:PYLAST_API_KEY:} + PYLAST_API_SECRET={env:PYLAST_API_SECRET:} deps = pyyaml pytest