def test_backup(self): pl_path = Path(self.library.pl_dir) fn = FileBackedPlaylist.filename_for(PL_NAME) backup = (pl_path / ".backup" / fn) assert backup.exists(), "Didn't backup" with open(backup) as f: lines = f.readlines() assert len(lines) == 3
def create_playlist_file(self, pl_dir) -> None: # Won't exist, we haven't started the library yet temp_path = Path(_TEMP_DIR).absolute() parents = {path.absolute() for path in pl_dir.parents} assert temp_path in parents or os.environ.get('CI', False), "Dangerous test!" shutil.rmtree(pl_dir, ignore_errors=True) os.makedirs(pl_dir) fn = FileBackedPlaylist.filename_for(PL_NAME) # No PL library given - rely on import self.pl = pl = FileBackedPlaylist(str(pl_dir), fn, self.underlying, None) pl.extend(list(sorted(self.underlying))[-3:]) assert len(pl) == 3, "Should have only the three songs just added" diff = set(self.underlying) - set(pl) assert all(song in self.underlying for song in pl), f"Missing from lib: {diff}" pl.finalize() pl.write()
def test_old_playlist_removed(self): pl_path = Path(self.library.pl_dir) fn = FileBackedPlaylist.filename_for(PL_NAME) old_path = pl_path / fn assert not old_path.exists(), "Didn't remove old playlist" assert len(self.library) == 1