From 7a3072b52cbfdde1053b30145d3a8dd22dcf234e Mon Sep 17 00:00:00 2001 From: hugovk Date: Mon, 17 Mar 2014 23:14:51 +0200 Subject: [PATCH] Add some Playlist tests --- test_pylast.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test_pylast.py b/test_pylast.py index 9874c8b..236a155 100755 --- a/test_pylast.py +++ b/test_pylast.py @@ -1442,6 +1442,42 @@ class TestPyLast(unittest.TestCase): self.assertEqual(playlist.get_duration(), 0) self.assertFalse(playlist.is_streamable()) + def test_big_playlist_is_streamable(self): + # Arrange + # Find a big playlist on Last.fm, eg "top 100 classick rock songs" + user = "kaxior" + id = 10417943 + playlist = pylast.Playlist(user, id, self.network) + self.assertEqual( + playlist.get_url(), + "http://www.last.fm/user/kaxior/library/" + "playlists/67ajb_top_100_classick_rock_songs") + + # Act + # Nothing + + # Assert + self.assertIsInstance(playlist, pylast.Playlist) + self.assertGreaterEqual(playlist.get_size(), 45) + self.assertGreater(playlist.get_duration(), 0) + self.assertTrue(playlist.is_streamable()) + + def test_add_track_to_playlist(self): + # Arrange + title = "One track playlist" + description = "Testing" + playlist = self.network.create_new_playlist(title, description) + track = pylast.Track("Test Artist", "Test Title", self.network) + + # Act + playlist.add_track(track) + + # Assert + self.assertEqual(playlist.get_size(), 1) + self.assertEqual(len(playlist.get_tracks()), 1) + self.assertTrue(playlist.has_track(track)) + + if __name__ == '__main__': parser = argparse.ArgumentParser(