mirror of
https://github.com/darkzoul5/YoutubePlaylistSync.git
synced 2026-09-21 22:12:19 +03:00
establish config defaults
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from src.app.config.settings import Settings
|
||||
@@ -18,6 +19,10 @@ def test_settings_creates_root_config_if_missing(tmp_path, monkeypatch):
|
||||
|
||||
data = json.loads(cfg_path.read_text(encoding="utf-8"))
|
||||
assert "playlists" in data
|
||||
assert data.get("ffmpeg_path") == ("./bin/ffmpeg.exe" if os.name == "nt" else "./bin/ffmpeg")
|
||||
assert data["playlists"][0].get("download_mode") == "video"
|
||||
assert data["playlists"][0].get("max_download_quality") == "1080p"
|
||||
assert data["playlists"][0].get("save_path") == "./downloads"
|
||||
|
||||
|
||||
def test_settings_reads_config_from_default_location(tmp_path, monkeypatch):
|
||||
@@ -25,8 +30,11 @@ def test_settings_reads_config_from_default_location(tmp_path, monkeypatch):
|
||||
|
||||
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")
|
||||
cfg_path.write_text(json.dumps({"playlists": [{"url": "X"}]}), encoding="utf-8")
|
||||
|
||||
settings = Settings()
|
||||
assert settings.path == cfg_path.resolve()
|
||||
assert settings.playlists and settings.playlists[0]["url"] == "X"
|
||||
assert settings.playlists[0]["download_mode"] == "video"
|
||||
assert settings.playlists[0]["max_download_quality"] == "1080p"
|
||||
assert settings.playlists[0]["save_path"] == "./downloads"
|
||||
|
||||
Reference in New Issue
Block a user