feat: rebuild AI commands and migrate config to TOML
This commit is contained in:
44
tests/test_config_toml.py
Normal file
44
tests/test_config_toml.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.config import load_app_config
|
||||
|
||||
|
||||
class TomlConfigTests(unittest.TestCase):
|
||||
def test_loads_default_toml_config(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
root = Path(temp_dir)
|
||||
(root / "config.toml").write_text(
|
||||
"""
|
||||
api_id = 123456
|
||||
api_hash = "hash"
|
||||
session_dir = "sessions"
|
||||
|
||||
[[accounts]]
|
||||
name = "personal"
|
||||
session = "personal"
|
||||
|
||||
[elevenlabs]
|
||||
api_key = "test-key"
|
||||
model_id = "scribe_v2"
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
with patch.dict("os.environ", {}, clear=True):
|
||||
config = load_app_config(root)
|
||||
|
||||
self.assertEqual(config.api_id, 123456)
|
||||
self.assertEqual(config.accounts[0].session, "personal")
|
||||
self.assertEqual(config.elevenlabs.api_key, "test-key")
|
||||
self.assertEqual(config.session_dir, root / "sessions")
|
||||
self.assertEqual(config.ai.prompt_dir, root / "prompts")
|
||||
self.assertEqual(config.ai.base_dir, root)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user