def test_load_legacy_format_to_xspf(self): playlist_fn = "old" songs_lib = FileLibrary() songs_lib.add(NUMERIC_SONGS) old_pl = FileBackedPlaylist(self.temp, playlist_fn) old_pl.extend(NUMERIC_SONGS) pl = XSPFBackedPlaylist.from_playlist(old_pl, songs_lib=songs_lib, pl_lib=None) expected_filenames = {s("~filename") for s in NUMERIC_SONGS} assert {s("~filename") for s in pl.songs} == expected_filenames
def test_import(self): pl_name = u"_€3 œufs à Noël" pl = FileBackedPlaylist(_TEMP_DIR, pl_name, None) pl.extend(SONGS) pl.write() new_fn = os.path.splitext(text2fsn(pl.name))[0] + '.m3u' new_path = os.path.join(pl.dir, new_fn) os.rename(pl.filename, new_path) added = self.bar._import_playlists([new_path], self.lib) self.failUnlessEqual(added, 1, msg="Failed to add '%s'" % new_path) os.unlink(new_path) pls = self.bar.playlists() self.failUnlessEqual(len(pls), 3) # Leading underscore makes it always the last entry imported = pls[-1] self.failUnlessEqual(imported.name, pl_name) def fns(songs): return [song('~filename') for song in songs] self.failUnlessEqual(fns(imported.songs), fns(pl.songs))
def test_import(self): pl_name = u"_€3 œufs à Noël" pl = FileBackedPlaylist(_TEMP_DIR, pl_name, None) pl.extend(SONGS) pl.write() new_fn = os.path.splitext(text2fsn(pl.name))[0] + '.m3u' new_path = os.path.join(pl.dir, new_fn) os.rename(pl.filename, new_path) added = self.bar._import_playlists([new_path], self.lib) self.failUnlessEqual(added, 1, msg="Failed to add '%s'" % new_path) os.unlink(new_path) pls = self.bar.playlists() self.failUnlessEqual(len(pls), 3) # Leading underscore makes it always the last entry imported = pls[-1] self.failUnlessEqual(imported.name, pl_name) def fns(songs): return [song('~filename') for song in songs] self.failUnlessEqual(fns(imported.songs), fns(pl.songs))