From 36f7e9619b3e62d4d82e000a61e98e1e92c8751f Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 1 Mar 2018 11:19:34 +0200 Subject: [PATCH 1/3] Shorten test names --- tests/{test_pylast_album.py => test_album.py} | 0 tests/{test_pylast_artist.py => test_artist.py} | 0 tests/{test_pylast_country.py => test_country.py} | 0 tests/{test_pylast_library.py => test_library.py} | 0 tests/{test_pylast_librefm.py => test_librefm.py} | 0 tests/{test_pylast_network.py => test_network.py} | 0 tests/{test_pylast_tag.py => test_tag.py} | 0 tests/{test_pylast_track.py => test_track.py} | 0 tests/{test_pylast_user.py => test_user.py} | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename tests/{test_pylast_album.py => test_album.py} (100%) rename tests/{test_pylast_artist.py => test_artist.py} (100%) rename tests/{test_pylast_country.py => test_country.py} (100%) rename tests/{test_pylast_library.py => test_library.py} (100%) rename tests/{test_pylast_librefm.py => test_librefm.py} (100%) rename tests/{test_pylast_network.py => test_network.py} (100%) rename tests/{test_pylast_tag.py => test_tag.py} (100%) rename tests/{test_pylast_track.py => test_track.py} (100%) rename tests/{test_pylast_user.py => test_user.py} (100%) diff --git a/tests/test_pylast_album.py b/tests/test_album.py similarity index 100% rename from tests/test_pylast_album.py rename to tests/test_album.py diff --git a/tests/test_pylast_artist.py b/tests/test_artist.py similarity index 100% rename from tests/test_pylast_artist.py rename to tests/test_artist.py diff --git a/tests/test_pylast_country.py b/tests/test_country.py similarity index 100% rename from tests/test_pylast_country.py rename to tests/test_country.py diff --git a/tests/test_pylast_library.py b/tests/test_library.py similarity index 100% rename from tests/test_pylast_library.py rename to tests/test_library.py diff --git a/tests/test_pylast_librefm.py b/tests/test_librefm.py similarity index 100% rename from tests/test_pylast_librefm.py rename to tests/test_librefm.py diff --git a/tests/test_pylast_network.py b/tests/test_network.py similarity index 100% rename from tests/test_pylast_network.py rename to tests/test_network.py diff --git a/tests/test_pylast_tag.py b/tests/test_tag.py similarity index 100% rename from tests/test_pylast_tag.py rename to tests/test_tag.py diff --git a/tests/test_pylast_track.py b/tests/test_track.py similarity index 100% rename from tests/test_pylast_track.py rename to tests/test_track.py diff --git a/tests/test_pylast_user.py b/tests/test_user.py similarity index 100% rename from tests/test_pylast_user.py rename to tests/test_user.py From b87fefe9ab1478a86074939b4617d91efcd32957 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 1 Mar 2018 11:23:06 +0200 Subject: [PATCH 2/3] Move track tests to test_track.py --- tests/test_track.py | 79 +++++++++++++++++++++++++++++++++++++++++++++ tests/test_user.py | 79 --------------------------------------------- 2 files changed, 79 insertions(+), 79 deletions(-) diff --git a/tests/test_track.py b/tests/test_track.py index 6add41e..25bba36 100755 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -170,6 +170,85 @@ class TestPyLastTrack(PyLastTestCase): self.assertGreaterEqual(len(track.get_similar(limit=None)), 23) self.assertGreaterEqual(len(track.get_similar(limit=0)), 23) + def test_tracks_notequal(self): + # Arrange + track1 = pylast.Track("Test Artist", "test title", self.network) + track2 = pylast.Track("Test Artist", "Test Track", self.network) + + # Act + # Assert + self.assertNotEqual(track1, track2) + + def test_track_title_prop_caps(self): + # Arrange + track = pylast.Track("test artist", "test title", self.network) + + # Act + title = track.get_title(properly_capitalized=True) + + # Assert + self.assertEqual(title, "Test Title") + + def test_track_listener_count(self): + # Arrange + track = pylast.Track("test artist", "test title", self.network) + + # Act + count = track.get_listener_count() + + # Assert + self.assertGreater(count, 21) + + def test_album_tracks(self): + # Arrange + album = pylast.Album("Test Artist", "Test Release", self.network) + + # Act + tracks = album.get_tracks() + url = tracks[0].get_url() + + # Assert + self.assertIsInstance(tracks, list) + self.assertIsInstance(tracks[0], pylast.Track) + self.assertEqual(len(tracks), 4) + self.assertTrue(url.startswith("https://www.last.fm/music/test")) + + def test_track_eq_none_is_false(self): + # Arrange + track1 = None + track2 = pylast.Track("Test Artist", "test title", self.network) + + # Act / Assert + self.assertNotEqual(track1, track2) + + def test_track_ne_none_is_true(self): + # Arrange + track1 = None + track2 = pylast.Track("Test Artist", "test title", self.network) + + # Act / Assert + self.assertNotEqual(track1, track2) + + 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") + + def test_track_with_no_mbid(self): + # Arrange + track = pylast.Track("Static-X", "Set It Off", self.network) + + # Act + mbid = track.get_mbid() + + # Assert + self.assertIsNone(mbid) + if __name__ == '__main__': unittest.main(failfast=True) diff --git a/tests/test_user.py b/tests/test_user.py index ad12feb..70a69e8 100755 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -374,85 +374,6 @@ class TestPyLastUser(PyLastTestCase): self.assertEqual(str(tracks[0].track.artist), "Johnny Cash") self.assertEqual(str(tracks[0].track.title), "Ring of Fire") - def test_tracks_notequal(self): - # Arrange - track1 = pylast.Track("Test Artist", "test title", self.network) - track2 = pylast.Track("Test Artist", "Test Track", self.network) - - # Act - # Assert - self.assertNotEqual(track1, track2) - - def test_track_title_prop_caps(self): - # Arrange - track = pylast.Track("test artist", "test title", self.network) - - # Act - title = track.get_title(properly_capitalized=True) - - # Assert - self.assertEqual(title, "Test Title") - - def test_track_listener_count(self): - # Arrange - track = pylast.Track("test artist", "test title", self.network) - - # Act - count = track.get_listener_count() - - # Assert - self.assertGreater(count, 21) - - def test_album_tracks(self): - # Arrange - album = pylast.Album("Test Artist", "Test Release", self.network) - - # Act - tracks = album.get_tracks() - url = tracks[0].get_url() - - # Assert - self.assertIsInstance(tracks, list) - self.assertIsInstance(tracks[0], pylast.Track) - self.assertEqual(len(tracks), 4) - self.assertTrue(url.startswith("https://www.last.fm/music/test")) - - def test_track_eq_none_is_false(self): - # Arrange - track1 = None - track2 = pylast.Track("Test Artist", "test title", self.network) - - # Act / Assert - self.assertNotEqual(track1, track2) - - def test_track_ne_none_is_true(self): - # Arrange - track1 = None - track2 = pylast.Track("Test Artist", "test title", self.network) - - # Act / Assert - self.assertNotEqual(track1, track2) - - 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") - - def test_track_with_no_mbid(self): - # Arrange - track = pylast.Track("Static-X", "Set It Off", self.network) - - # Act - mbid = track.get_mbid() - - # Assert - self.assertIsNone(mbid) - def test_get_playcount(self): # Arrange user = self.network.get_user("RJ") From acdc23d7e76510fc28126c6ee20422af9412a3b2 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 1 Mar 2018 11:24:53 +0200 Subject: [PATCH 3/3] Fix test case for changed test data --- tests/test_track.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_track.py b/tests/test_track.py index 25bba36..efa0812 100755 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -201,7 +201,7 @@ class TestPyLastTrack(PyLastTestCase): def test_album_tracks(self): # Arrange - album = pylast.Album("Test Artist", "Test Release", self.network) + album = pylast.Album("Test Artist", "Test", self.network) # Act tracks = album.get_tracks() @@ -210,7 +210,7 @@ class TestPyLastTrack(PyLastTestCase): # Assert self.assertIsInstance(tracks, list) self.assertIsInstance(tracks[0], pylast.Track) - self.assertEqual(len(tracks), 4) + self.assertEqual(len(tracks), 1) self.assertTrue(url.startswith("https://www.last.fm/music/test")) def test_track_eq_none_is_false(self):