def test_read(self): lib = FileLibrary("foobar") lib.add(NUMERIC_SONGS) with self.wrap("playlist", lib) as pl: pl.extend(NUMERIC_SONGS) pl.write() self.assertEqual(len(pl), len(NUMERIC_SONGS))
def test_masked_handling(self): if os.name == "nt": # FIXME: masking isn't properly implemented on Windows return # playlists can contain songs and paths for masked handling.. lib = FileLibrary("foobar") with self.wrap("playlist", lib) as pl: song = Fakesong({"date": "2038", "~filename": fsnative(u"/fake")}) song.sanitize() lib.add([song]) # mask and update lib.mask("/") pl.append(song) pl.remove_songs([song]) self.failUnless("/fake" in pl) pl.extend(self.TWO_SONGS) # check if collections can handle the mix self.failUnlessEqual(pl("date"), "2038") # unmask and update lib.unmask("/") pl.add_songs(["/fake"], lib) self.failUnless(song in pl) lib.destroy()
def test_masked_handling(self): if os.name == "nt": # FIXME: masking isn't properly implemented on Windows return # playlists can contain songs and paths for masked handling.. lib = FileLibrary("foobar") pl = Playlist(self.temp, "playlist", lib) song = Fakesong({"date": "2038", "~filename": fsnative(u"/fake")}) song.sanitize() lib.add([song]) # mask and update lib.mask("/") pl.append(song) pl.remove_songs([song]) self.failUnless("/fake" in pl) pl.extend(self.TWO_SONGS) # check if collections can handle the mix self.failUnlessEqual(pl("date"), "2038") # unmask and update lib.unmask("/") pl.add_songs(["/fake"], lib) self.failUnless(song in pl) pl.delete() lib.destroy()
def test_read(self): pl = Playlist(self.temp, "playlist") pl.extend(NUMERIC_SONGS) pl.write() lib = FileLibrary("foobar") lib.add(NUMERIC_SONGS) pl = Playlist(self.temp, "playlist", lib) self.assertEqual(len(pl), len(NUMERIC_SONGS))
def test_read(self): with self.wrap("playlist") as pl: pl.extend(NUMERIC_SONGS) pl.write() lib = FileLibrary("foobar") lib.add(NUMERIC_SONGS) pl = self.pl("playlist", lib) self.assertEqual(len(pl), len(NUMERIC_SONGS))
def test_difficult_names(self): lib = FileLibrary("foobar") lib.add(NUMERIC_SONGS) name = "c:?\"problem?\" / foo* / 100% É™! COM" with self.wrap(name, lib) as pl: pl.extend(NUMERIC_SONGS) pl.write() assert pl.songs == NUMERIC_SONGS with self.wrap(name, lib) as pl2: assert pl2.songs == NUMERIC_SONGS
class TPlaylistMenu(TestCase): SONG = AudioFile({ "title": "two", "artist": "mu", "~filename": dummy_path(u"/dev/zero") }) SONGS = [ AudioFile({ "title": "one", "artist": "piman", "~filename": dummy_path(u"/dev/null") }), SONG, ] def setUp(self): # Testing locally is VERY dangerous without this... self.assertTrue(_TEMP_DIR in PLAYLISTS or os.name == "nt", msg="Failing, don't want to delete %s" % PLAYLISTS) try: os.mkdir(PLAYLISTS) except EnvironmentError: pass quodlibet.config.init() self.lib = FileLibrary() self.lib.librarian = SongLibrarian() for af in self.SONGS: af.sanitize() self.lib.add(self.SONGS) self.added = [] def tearDown(self): self.lib.destroy() self.lib.librarian.destroy() quodlibet.config.quit() def _on_new(self, _, playlist): self.added.append(playlist) def test__on_new_playlist_activate(self): main = qltk.MenuItem('Menu') menu = StubbedPlaylistMenu(self.SONGS, []) menu.connect('new', self._on_new) main.set_submenu(menu) menu._on_new_playlist_activate(main, self.SONGS) self.failUnless(self.added, msg="No playlists signalled") self.failUnlessEqual(self.added[0].songs, self.SONGS) self.added[0].delete()
class TPlaylistMenu(TestCase): SONG = AudioFile({ "title": "two", "artist": "mu", "~filename": dummy_path(u"/dev/zero")}) SONGS = [ AudioFile({ "title": "one", "artist": "piman", "~filename": dummy_path(u"/dev/null")}), SONG, ] def setUp(self): # Testing locally is VERY dangerous without this... self.assertTrue(_TEMP_DIR in PLAYLISTS or os.name == "nt", msg="Failing, don't want to delete %s" % PLAYLISTS) try: os.mkdir(PLAYLISTS) except IOError: pass quodlibet.config.init() self.lib = FileLibrary() self.lib.librarian = SongLibrarian() for af in self.SONGS: af.sanitize() self.lib.add(self.SONGS) self.added = [] def tearDown(self): self.lib.destroy() self.lib.librarian.destroy() quodlibet.config.quit() def _on_new(self, _, playlist): self.added.append(playlist) def test__on_new_playlist_activate(self): main = qltk.MenuItem('Menu') menu = StubbedPlaylistMenu(self.SONGS, [], self.lib) menu.connect('new', self._on_new) main.set_submenu(menu) menu._on_new_playlist_activate(main, self.SONGS) self.failUnless(self.added, msg="No playlists signalled") self.failUnlessEqual(self.added[0].songs, self.SONGS) self.added[0].delete()