34 lines
1.1 KiB
Python
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
|