"""Fixtures for application-layer tests.""" import shutil import tempfile import pytest from alfred.infrastructure.persistence import Memory, set_memory @pytest.fixture def app_temp(tmp_path): """Real folder structure: downloads, movies, tv_shows, torrents.""" (tmp_path / "downloads").mkdir() (tmp_path / "movies").mkdir() (tmp_path / "tv_shows").mkdir() (tmp_path / "torrents").mkdir() return tmp_path @pytest.fixture def memory_configured(app_temp, tmp_path): """ Fresh Memory with library_paths and workspace configured using the real API. Replaces the broken memory_with_config from root conftest for these tests. """ storage = tempfile.mkdtemp() mem = Memory(storage_dir=storage) set_memory(mem) mem.ltm.workspace.download = str(app_temp / "downloads") mem.ltm.workspace.torrent = str(app_temp / "torrents") mem.ltm.library_paths.set("movie", str(app_temp / "movies")) mem.ltm.library_paths.set("tv_show", str(app_temp / "tv_shows")) mem.save() yield mem shutil.rmtree(storage, ignore_errors=True)