50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
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"
|
|
use_qr = true
|
|
|
|
[elevenlabs]
|
|
api_key = "test-key"
|
|
model_id = "scribe_v2"
|
|
|
|
[ai]
|
|
prompt_dir = "custom-prompts"
|
|
""".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.assertTrue(config.accounts[0].use_qr)
|
|
self.assertEqual(config.elevenlabs.api_key, "test-key")
|
|
self.assertEqual(config.session_dir, root / "sessions")
|
|
self.assertEqual(config.ai.prompt_dir, root / "custom-prompts")
|
|
self.assertEqual(config.ai.base_dir, root)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|