diff --git a/tests/test_config.py b/tests/test_config.py index a73a14b..a942ada 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,4 +1,6 @@ from pathlib import Path +from unittest.mock import patch +import os import tomllib from whisper_local.config import Config, load_config @@ -57,3 +59,20 @@ class TestLoadConfig: config_file.write_text("") config = load_config(config_file) assert config.hotkey == "KEY_F12" + + +class TestConfigPath: + @patch.dict(os.environ, {"APPDATA": "C:\\Users\\test\\AppData\\Roaming"}) + @patch("whisper_local.config.sys") + def test_windows_config_path(self, mock_sys): + mock_sys.platform = "win32" + from whisper_local.config import _default_config_path + result = _default_config_path() + assert result == Path("C:\\Users\\test\\AppData\\Roaming") / "whisper-local" / "config.toml" + + @patch("whisper_local.config.sys") + def test_linux_config_path(self, mock_sys): + mock_sys.platform = "linux" + from whisper_local.config import _default_config_path + result = _default_config_path() + assert result == Path.home() / ".config" / "whisper-local" / "config.toml" diff --git a/whisper_local/config.py b/whisper_local/config.py index 17c0e94..c2873e9 100644 --- a/whisper_local/config.py +++ b/whisper_local/config.py @@ -1,11 +1,19 @@ """Konfiguration aus TOML-Datei mit sinnvollen Defaults.""" +import os +import sys from dataclasses import dataclass from pathlib import Path import tomllib -DEFAULT_CONFIG_PATH = Path.home() / ".config" / "whisper-local" / "config.toml" +def _default_config_path() -> Path: + if sys.platform == "win32": + return Path(os.environ.get("APPDATA", "")) / "whisper-local" / "config.toml" + return Path.home() / ".config" / "whisper-local" / "config.toml" + + +DEFAULT_CONFIG_PATH = _default_config_path() @dataclass