Files
streamrip-ui/backend/tests/test_config_autocreate.py
T
loki 4b915d3b52
CI / backend-tests (push) Successful in 8s
Docker images / version (push) Successful in 2s
CI / docker (push) Successful in 5s
Docker images / backend (push) Successful in 5s
Docker images / frontend (push) Successful in 5s
feat: config.toml wird automatisch angelegt wenn fehlend
2026-10-04 13:31:08 +02:00

34 lines
1.1 KiB
Python

from app.core import settings
def test_missing_config_is_created_with_defaults(tmp_path, monkeypatch):
from app.services.streamrip_service import _load_config
cfg = tmp_path / "sub" / "config.toml"
dl = tmp_path / "dl"
dl.mkdir()
monkeypatch.setattr(settings, "CONFIG_PATH", str(cfg))
monkeypatch.setattr(settings, "DOWNLOAD_DIR", str(dl))
config = _load_config()
assert cfg.exists()
assert config.session.downloads.folder == str(dl)
# ARL empty -> user must add it via UI
assert config.session.deezer.arl == ""
def test_existing_config_is_not_touched(tmp_path, monkeypatch):
from app.services.streamrip_service import _load_config
cfg = tmp_path / "config.toml"
cfg.write_text('[downloads]\nfolder = "/keep/me"\n')
monkeypatch.setattr(settings, "CONFIG_PATH", str(cfg))
# minimal file: _load_config must not overwrite, only streamrip decides
before = cfg.read_text()
try:
_load_config()
except Exception:
pass # streamrip may reject incomplete files - must not have overwritten
assert cfg.read_text() == before