Files
alfred/tests/infrastructure/conftest.py
T
2026-05-26 21:45:11 +02:00

43 lines
1.2 KiB
Python

"""Fixtures for infrastructure-layer tests."""
import shutil
import tempfile
import pytest
from alfred.infrastructure.persistence_TO_CHECK import Memory, set_memory
@pytest.fixture
def infra_temp(tmp_path):
"""Real folder layout: downloads (with files), movies, tv_shows, torrents."""
dl = tmp_path / "downloads"
dl.mkdir()
(dl / "test_movie.mkv").write_bytes(b"fake video")
series_dir = dl / "test_series"
series_dir.mkdir()
(series_dir / "episode1.mkv").write_bytes(b"fake episode")
(tmp_path / "movies").mkdir()
(tmp_path / "tv_shows").mkdir()
(tmp_path / "torrents").mkdir()
return tmp_path
@pytest.fixture
def memory_configured(infra_temp):
"""Fresh Memory configured with the real workspace/library_paths API."""
storage = tempfile.mkdtemp()
mem = Memory(storage_dir=storage)
set_memory(mem)
mem.ltm.workspace.download = str(infra_temp / "downloads")
mem.ltm.workspace.torrent = str(infra_temp / "torrents")
mem.ltm.library_paths.set("movie", str(infra_temp / "movies"))
mem.ltm.library_paths.set("tv_show", str(infra_temp / "tv_shows"))
mem.save()
yield mem
shutil.rmtree(storage, ignore_errors=True)