test: add test suite for player, api and widgets
This commit is contained in:
1 parent
237de2efe9
commit
8eb22ea52c
11 files changed
+1069
No files matched your search
@@ -0,0 +1,38 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
os.environ["SOMAFM_IMAGES"] = "0"
|
||||
|
||||
import pytest
|
||||
|
||||
from somafm_tui import api, config
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def isolated_state(tmp_path, monkeypatch):
|
||||
"""Keep tests out of the real ~/.config and ~/.cache."""
|
||||
config_dir = tmp_path / "config"
|
||||
cache_dir = tmp_path / "cache"
|
||||
songs_dir = cache_dir / "songs"
|
||||
runtime_dir = tmp_path / "run"
|
||||
|
||||
for attr, value in (
|
||||
("CONFIG_DIR", config_dir),
|
||||
("CACHE_DIR", cache_dir),
|
||||
("SONGS_CACHE_DIR", songs_dir),
|
||||
("RUNTIME_DIR", runtime_dir),
|
||||
("CONFIG_PATH", config_dir / "config.json"),
|
||||
("CHANNELS_CACHE", cache_dir / "channels.json"),
|
||||
("PLAYLIST_CACHE", cache_dir / "playlists.json"),
|
||||
):
|
||||
monkeypatch.setattr(config, attr, value)
|
||||
|
||||
def ensure_dirs() -> None:
|
||||
for path in (config_dir, cache_dir, songs_dir, runtime_dir):
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
monkeypatch.setattr(config, "ensure_dirs", ensure_dirs)
|
||||
monkeypatch.setattr(api, "_PLAYLIST_CACHE", None)
|
||||
ensure_dirs()
|
||||
yield
|
||||
Reference in new issue
Block a user