1
0
mirror of https://github.com/darkzoul5/YoutubePlaylistSync.git synced 2026-07-03 04:23:59 +03:00

feat: make sure max_video_quality setting is working

This commit is contained in:
2026-05-16 16:07:52 +03:00
parent 4cd6255b0f
commit 1928f70928
9 changed files with 118 additions and 18 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ class DummyConfig:
max_parallel_downloads = int(os.getenv("TEST_MAX_PARALLEL", "2"))
aria2c_connections = int(os.getenv("TEST_ARIA2C_CONN", "2"))
download_mode = os.getenv("TEST_DOWNLOAD_MODE", "audio")
max_video_quality = os.getenv("TEST_MAX_VIDEO_QUALITY", "1080p")
max_download_quality = os.getenv("TEST_MAX_DOWNLOAD_QUALITY", "1080p")
# runtime flags
debug = False
non_interactive = False
+15
View File
@@ -0,0 +1,15 @@
from __future__ import annotations
from src.app.core.download.downloader import Downloader
def test_build_format_defaults_to_best_mp4():
fmt = Downloader.build_format(None)
assert "height<=" not in fmt
assert "best[ext=mp4]" in fmt
def test_build_format_applies_height_cap():
fmt = Downloader.build_format("720p")
assert "height<=720" in fmt
+32
View File
@@ -0,0 +1,32 @@
from __future__ import annotations
import json
from pathlib import Path
from src.app.config.settings import Settings
def test_settings_creates_root_config_if_missing(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
cfg_path = tmp_path / "config" / "yt-playlist-config.json"
assert not cfg_path.exists()
settings = Settings()
assert settings.path == cfg_path.resolve()
assert cfg_path.exists()
data = json.loads(cfg_path.read_text(encoding="utf-8"))
assert "playlists" in data
def test_settings_reads_config_from_default_location(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
cfg_path = tmp_path / "config" / "yt-playlist-config.json"
cfg_path.parent.mkdir(parents=True, exist_ok=True)
cfg_path.write_text(json.dumps({"playlists": [{"url": "X", "save_path": "./downloads"}]}), encoding="utf-8")
settings = Settings()
assert settings.path == cfg_path.resolve()
assert settings.playlists and settings.playlists[0]["url"] == "X"