Auto-fill ČSFD links on import, rename in pool, multi-country tags, Filmotéka layout
This commit is contained in:
@@ -261,3 +261,72 @@ class TestFile:
|
||||
tag_paths2 = {tag.full_path for tag in file_obj2.tags}
|
||||
assert tag_paths == tag_paths2
|
||||
assert file_obj2.date == "2025-01-01"
|
||||
|
||||
|
||||
class TestApplyCsfdTags:
|
||||
"""Tests for File.apply_csfd_tags tag assignment (CSFD fetch is mocked)."""
|
||||
|
||||
@pytest.fixture
|
||||
def tag_manager(self):
|
||||
return TagManager()
|
||||
|
||||
@pytest.fixture
|
||||
def movie_file(self, tmp_path, tag_manager):
|
||||
path = tmp_path / "Matrix.mkv"
|
||||
path.write_text("x")
|
||||
f = File(path, tag_manager)
|
||||
f.set_csfd_link("https://www.csfd.cz/film/9499-matrix/")
|
||||
return f
|
||||
|
||||
def test_apply_csfd_tags_assigns_expected_categories(self, movie_file):
|
||||
from unittest.mock import patch
|
||||
from src.core.csfd import CSFDMovie
|
||||
|
||||
movie = CSFDMovie(
|
||||
title="Matrix", url="u", year=1999, genres=["Akční", "Sci-Fi"],
|
||||
directors=["Lana Wachowski", "Lilly Wachowski"],
|
||||
actors=["Keanu Reeves", "Laurence Fishburne"],
|
||||
rating=90, countries=["USA"],
|
||||
)
|
||||
with patch("src.core.csfd.fetch_movie", return_value=movie):
|
||||
result = movie_file.apply_csfd_tags()
|
||||
|
||||
assert result["success"]
|
||||
paths = {t.full_path for t in movie_file.tags}
|
||||
assert "Žánr/Akční" in paths
|
||||
assert "Žánr/Sci-Fi" in paths
|
||||
assert "Rok/1999" in paths
|
||||
assert "Země původu/USA" in paths
|
||||
assert "Hodnocení/90–100 %" in paths
|
||||
|
||||
def test_apply_csfd_tags_does_not_tag_directors_or_actors(self, movie_file):
|
||||
"""Režie/herci se jen cachují, netvoří se z nich tagy (bylo by jich moc)."""
|
||||
from unittest.mock import patch
|
||||
from src.core.csfd import CSFDMovie
|
||||
|
||||
movie = CSFDMovie(
|
||||
title="Matrix", url="u", directors=["Lana Wachowski"],
|
||||
actors=["Keanu Reeves", "Laurence Fishburne"], genres=["Drama"],
|
||||
)
|
||||
with patch("src.core.csfd.fetch_movie", return_value=movie):
|
||||
movie_file.apply_csfd_tags()
|
||||
|
||||
paths = {t.full_path for t in movie_file.tags}
|
||||
assert not any(p.startswith("Režie/") for p in paths)
|
||||
assert not any(p.startswith("Herec/") for p in paths)
|
||||
# …but the data is kept in the cache
|
||||
cached = movie_file.get_cached_movie()
|
||||
assert cached.directors == ["Lana Wachowski"]
|
||||
assert cached.actors == ["Keanu Reeves", "Laurence Fishburne"]
|
||||
|
||||
def test_apply_csfd_tags_can_skip_rating(self, movie_file):
|
||||
from unittest.mock import patch
|
||||
from src.core.csfd import CSFDMovie
|
||||
|
||||
movie = CSFDMovie(title="Matrix", url="u", rating=90, genres=["Drama"])
|
||||
with patch("src.core.csfd.fetch_movie", return_value=movie):
|
||||
movie_file.apply_csfd_tags(add_rating=False)
|
||||
|
||||
paths = {t.full_path for t in movie_file.tags}
|
||||
assert "Žánr/Drama" in paths
|
||||
assert not any(p.startswith("Hodnocení/") for p in paths)
|
||||
|
||||
Reference in New Issue
Block a user