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: shutil.rmtree(PLAYLISTS) except OSError: pass mkdir(PLAYLISTS) self.lib = quodlibet.browsers.playlists.library = SongLibrary() self.lib.librarian = SongLibrarian() all_songs = SONGS + [self.ANOTHER_SONG] for af in all_songs: af.sanitize() self.lib.add(all_songs) self.big = pl = FileBackedPlaylist.new(PLAYLISTS, "Big", self.lib) pl.extend(SONGS) pl.write() self.small = pl = FileBackedPlaylist.new(PLAYLISTS, "Small", self.lib) pl.extend([self.ANOTHER_SONG]) pl.write() PlaylistsBrowser.init(self.lib) self.bar = PlaylistsBrowser(self.lib) self.bar.connect('songs-selected', self._expected) self.bar._select_playlist(self.bar.playlists()[0]) self.expected = None
def setUp(self): quodlibet.config.init() self.lib = quodlibet.browsers.search.library = FileLibrary() quodlibet.browsers.search.library.librarian = SongLibrarian() for af in self.SONGS: af.sanitize() self.lib.add(self.SONGS) self._dir = mkdtemp() self.pl = FileBackedPlaylist.new(self._dir, "Foobar", self.lib) self.pl.extend(self.SONGS)
def init(cache_fn=None): """Set up the library and return the main one. Return a main library, and set a librarian for all future SongLibraries. """ SongFileLibrary.librarian = SongLibrary.librarian = SongLibrarian() library = SongFileLibrary("main") if cache_fn: library.load(cache_fn) return library
def setUpClass(cls): # Only want to do this playlists setup once per test class... quodlibet.config.init() cls.lib = quodlibet.browsers.playlists.library = SongLibrary() cls.lib.librarian = SongLibrarian() all_songs = SONGS + [cls.ANOTHER_SONG] for af in all_songs: af.sanitize() cls.lib.add(all_songs) cls._create_temp_playlist_with("Big", SONGS) cls._create_temp_playlist_with("Small", [cls.ANOTHER_SONG]) PlaylistsBrowser.init(cls.lib)
def init(cache_fn=None): """Set up the library and return the main one. Return a main library, and set a librarian for all future SongLibraries. """ SongFileLibrary.librarian = SongLibrary.librarian = SongLibrarian() watch = config.getboolean("library", "watch") library = SongFileLibrary("main", watch_dirs=get_scan_dirs() if watch else []) if cache_fn: library.load(cache_fn) return library
def init(cache_fn=None): """Set up the library and return the main one. Return a main library, and set a librarian for all future SongLibraries. """ s = ", ".join(formats.modules) print_d("Supported formats: %s" % s) SongFileLibrary.librarian = SongLibrary.librarian = SongLibrarian() library = SongFileLibrary("main") if cache_fn: library.load(cache_fn) return library
def setUp(self): self.success = False # Testing locally is VERY dangerous without this... self.assertTrue(_TEMP_DIR in _DEFAULT_PLAYLIST_DIR or os.name == "nt", msg="Failing, don't want to delete %s" % _DEFAULT_PLAYLIST_DIR) try: shutil.rmtree(_DEFAULT_PLAYLIST_DIR) except OSError: pass mkdir(_DEFAULT_PLAYLIST_DIR) init_fake_app() self.lib = quodlibet.browsers.playlists.library = SongFileLibrary() self.lib.librarian = SongLibrarian() for af in self.ALL_SONGS: af.sanitize() self.lib.add(self.ALL_SONGS) self.big = pl = FileBackedPlaylist.new(_DEFAULT_PLAYLIST_DIR, "Big", self.lib, self.lib.playlists) pl.extend(SONGS) pl.write() self.small = pl = XSPFBackedPlaylist.new(_DEFAULT_PLAYLIST_DIR, "Small", self.lib, self.lib.playlists) pl.extend([self.ANOTHER_SONG]) pl.write() PlaylistsBrowser.init(self.lib) self.bar = PlaylistsBrowser(self.lib, self.MockConfirmerAccepting) self.bar.connect('songs-selected', self._expected) self.bar._select_playlist(self.bar.playlists()[0]) self.expected = None # Uses the declining confirmer. self.bar_decline = PlaylistsBrowser(self.lib, self.MockConfirmerDeclining) self.bar_decline.connect('songs-selected', self._expected_decline) self.bar_decline._select_playlist(self.bar_decline.playlists()[0]) # Note that _do() uses self.expected, but _do() is not called by the # testcase for declining the prompt. Tests fail with a shared expected. self.expected_decline = None
def init_fake_app(): from quodlibet import app from quodlibet import browsers from quodlibet.player.nullbe import NullPlayer from quodlibet.library.libraries import SongFileLibrary from quodlibet.library.librarians import SongLibrarian from quodlibet.qltk.quodlibetwindow import QuodLibetWindow from quodlibet.util.cover import CoverManager browsers.init() app.name = "Quod Libet" app.id = "quodlibet" app.player = NullPlayer() app.library = SongFileLibrary() app.library.librarian = SongLibrarian() app.cover_manager = CoverManager() app.window = QuodLibetWindow(app.library, app.player, headless=True)