feat: add microphone field and save_config to Config
This commit is contained in:
@@ -76,3 +76,32 @@ class TestConfigPath:
|
||||
from whisper_local.config import _default_config_path
|
||||
result = _default_config_path()
|
||||
assert result == Path.home() / ".config" / "whisper-local" / "config.toml"
|
||||
|
||||
|
||||
class TestMicrophoneConfig:
|
||||
def test_default_microphone_is_empty(self):
|
||||
config = Config()
|
||||
assert config.microphone == ""
|
||||
|
||||
def test_load_device_from_toml(self, tmp_path):
|
||||
config_file = tmp_path / "config.toml"
|
||||
config_file.write_text('[audio]\ndevice = "Headset Mic"\n')
|
||||
config = load_config(config_file)
|
||||
assert config.microphone == "Headset Mic"
|
||||
|
||||
|
||||
class TestSaveConfig:
|
||||
def test_save_and_reload(self, tmp_path):
|
||||
from whisper_local.config import save_config
|
||||
path = tmp_path / "config.toml"
|
||||
config = Config(hotkey="KEY_F8", microphone="USB Mic")
|
||||
save_config(config, path)
|
||||
loaded = load_config(path)
|
||||
assert loaded.hotkey == "KEY_F8"
|
||||
assert loaded.microphone == "USB Mic"
|
||||
|
||||
def test_save_creates_parent_dirs(self, tmp_path):
|
||||
from whisper_local.config import save_config
|
||||
path = tmp_path / "subdir" / "config.toml"
|
||||
save_config(Config(), path)
|
||||
assert path.exists()
|
||||
|
||||
Reference in New Issue
Block a user