Files
MoviePilot/tests/test_scraping_configuration.py
jxxghp fa67be8e4a fix(scraping): normalize artwork and reuse downloads for aliases
Add independent alias and Fanart 4K switches, identify exact artwork names, preserve episode and season conventions, and detect missing images across case and format variants. Normalize downloaded bytes to JPEG or PNG and reuse one request with storage hard links or local upload copies.

Refs #7128
2026-10-22 09:25:42 +08:00

41 lines
1.7 KiB
Python

"""
验证季图片落盘开关从部署配置传入刮削链快照。
"""
import pytest
from app.runtime.config import Settings
from app.startup.composition.configuration import build_chain_runtime_config
@pytest.mark.parametrize("env_value,expected", [(None, True), ("true", True), ("false", False)])
def test_season_image_root_setting_reaches_chain_snapshot(monkeypatch, tmp_path, env_value, expected) -> None:
"""
未配置时保持双写,环境变量可以显式启用或关闭根目录写入。
"""
monkeypatch.delenv("SCRAP_SEASON_IMAGE_TO_ROOT", raising=False)
if env_value is not None:
monkeypatch.setenv("SCRAP_SEASON_IMAGE_TO_ROOT", env_value)
settings = Settings(_env_file=None, CONFIG_DIR=str(tmp_path), API_TOKEN="0123456789abcdef")
assert settings.SCRAP_SEASON_IMAGE_TO_ROOT is expected
assert build_chain_runtime_config(settings).scrap_season_image_to_root is expected
@pytest.mark.parametrize("env_value,expected", [(None, True), ("true", True), ("false", False)])
@pytest.mark.parametrize("key,attribute", [
("SCRAP_IMAGE_ALIAS", "scrap_image_alias"),
("SCRAP_4K_BACKGROUND", "scrap_4k_background"),
])
def test_image_settings_reach_chain_snapshot(monkeypatch, tmp_path, key, attribute, env_value, expected) -> None:
"""
图片别名和 4K 背景开关默认兼容现状,并由部署配置传入刮削链。
"""
monkeypatch.delenv(key, raising=False)
if env_value is not None:
monkeypatch.setenv(key, env_value)
settings = Settings(_env_file=None, CONFIG_DIR=str(tmp_path), API_TOKEN="0123456789abcdef")
assert getattr(settings, key) is expected
assert getattr(build_chain_runtime_config(settings), attribute) is expected