Files
alfred/tests/application/movies/conftest.py
T
francwa 7ff2e6bc4e feat(movies): sync_movie populates library index from TMDB
Parallel to sync_show. Calls TMDBClient.get_movie_info,
combines the TmdbMovieInfo with the on-disk MovieRelease loaded
via DotAlfredMovieReleaseRepository.load_by_tmdb_id, and upserts
into DotAlfredMovieLibraryIndex.

Policy mirrors sync_show with two adaptations specific to movies:
* placeholder signature is name == metadata.path (auto-heal writes
  them equal — the schema requires name to be non-empty so we can't
  use name == "" as the spec originally suggested),
* when the per-movie sidecar is gone but the index entry remains,
  sync warns and returns the existing entry unchanged (no upsert
  possible without a release: index.upsert requires folder/imdb_id
  from the MovieRelease itself).

Raises MovieNotFoundInLibrary when neither index nor sidecar
carry tmdb_id.
2026-05-26 00:51:43 +02:00

50 lines
1.4 KiB
Python

"""Shared fixtures for ``alfred.application.movies`` tests."""
from __future__ import annotations
from datetime import UTC, datetime
import pytest
from alfred.domain.releases.entities import MovieRelease, TrackProfile
from alfred.domain.shared.media import AudioTrack
from alfred.domain.shared.value_objects import FilePath, ImdbId, TmdbId
@pytest.fixture
def movie_library(tmp_path):
"""Empty ``movies/`` with an Inception folder ready for sidecars."""
root = tmp_path / "movies"
root.mkdir()
(root / "Inception.2010.1080p.BluRay.x264-GROUP").mkdir()
return root
@pytest.fixture
def inception_release() -> MovieRelease:
"""Minimal Inception MovieRelease — enough for index assertions."""
return MovieRelease(
tmdb_id=TmdbId(27205),
imdb_id=ImdbId("tt1375666"),
folder="Inception.2010.1080p.BluRay.x264-GROUP",
file_path=FilePath("Inception.2010.1080p.BluRay.x264-GROUP.mkv"),
added_at=datetime(2026, 5, 25, 8, 30, 0, tzinfo=UTC),
tracks=TrackProfile(
audio_tracks=(
AudioTrack(
index=0,
codec="dts",
channels=8,
channel_layout="7.1",
language="eng",
),
),
),
)
@pytest.fixture
def now_utc() -> datetime:
"""Stable UTC reference for deterministic fetched_at fields."""
return datetime(2026, 5, 25, 8, 30, 0, tzinfo=UTC)