예제 #1
0
 def setUp(self):
     with playlist.open_playlist(test_user, refname, "w+") as outfile:
         outfile.write(test_playlist2_ref)
     with playlist.open_playlist(test_user, listname, "w+") as outfile:
         outfile.write(test_playlist2)
     with playlist.open_playlist(test_user, ref2name, "w+") as outfile:
         outfile.write(test_playlist3_ref)
     with playlist.open_playlist(test_user, list2name, "w+") as outfile:
         outfile.write(test_playlist3)
     with playlist.open_drainlist(test_user, dname, "w+") as outfile:
         outfile.write(test_drain2)
예제 #2
0
    def test_write_out(self):
        import copy
        plist2 = copy.copy(self.plist)
        plist2.uri = "test2"
        plist2.reference.uri = "test2"
        plist2.write_out()

        with playlist.open_playlist(test_user, "test2") as infile:
            for line in infile:
                self.assertTrue(all([i in line for i in ["t1", "t2", "t3"]]))
        with playlist.open_playlist(test_user, "test2_ref") as infile:
            for line in infile:
                self.assertTrue(all([i in line for i in ["t1", "t2", "t3"]]))

        os.remove(test_user + "/Playlists/" + "test2")
        os.remove(test_user + "/Playlists/" + "test2_ref")
예제 #3
0
class TestPlaylistMethods(unittest.TestCase):
    refname = "test_playlist_ref"
    listname = "test_playlist"

    with playlist.open_playlist(test_user, refname, "w+") as outfile:
        outfile.write(test_playlist_ref)
    with playlist.open_playlist(test_user, listname, "w+") as outfile:
        outfile.write(test_playlist)

    with playlist.open_playlist(test_user, refname, "r") as infile:
        ref = playlist.Playlist.from_file(test_user, infile, None)
    with playlist.open_playlist(test_user, listname, "r") as infile:
        plist = playlist.Playlist.from_file(test_user, infile, ref)

    os.remove(test_user + "/Playlists/" + refname)
    os.remove(test_user + "/Playlists/" + listname)

    def test_sync(self):
        self.assertEqual(self.plist.sync(), ["spotify:track:t3"])
        self.assertEqual(self.ref.tracks, self.plist.tracks)

    def test_write_out(self):
        import copy
        plist2 = copy.copy(self.plist)
        plist2.uri = "test2"
        plist2.reference.uri = "test2"
        plist2.write_out()

        with playlist.open_playlist(test_user, "test2") as infile:
            for line in infile:
                self.assertTrue(all([i in line for i in ["t1", "t2", "t3"]]))
        with playlist.open_playlist(test_user, "test2_ref") as infile:
            for line in infile:
                self.assertTrue(all([i in line for i in ["t1", "t2", "t3"]]))

        os.remove(test_user + "/Playlists/" + "test2")
        os.remove(test_user + "/Playlists/" + "test2_ref")
예제 #4
0
 def test_list_drains(self):
     drain_name = "test_drain"
     with playlist.open_playlist(test_user, drain_name, "w+") as outfile:
         outfile.write(test_playlist_ref)
     self.assertEqual(spotify.list_drains(test_user), ["test_drain"])
     os.remove(test_user + "/Playlists/" + drain_name)