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 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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")