refactor: remove GitHub webhook support
This commit is contained in:
73
tests/test_config_services.py
Normal file
73
tests/test_config_services.py
Normal file
@@ -0,0 +1,73 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from app.config import _parse_ai_config, _parse_elevenlabs_config
|
||||
|
||||
|
||||
class ConfigElevenLabsTests(unittest.TestCase):
|
||||
def test_elevenlabs_config_parses_values(self) -> None:
|
||||
with patch.dict("os.environ", {}, clear=True):
|
||||
config = _parse_elevenlabs_config(
|
||||
{
|
||||
"api_key": "config-key",
|
||||
"model_id": "scribe_v2",
|
||||
"language_code": "ru",
|
||||
"request_timeout_seconds": 120,
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(config.api_key, "config-key")
|
||||
self.assertEqual(config.model_id, "scribe_v2")
|
||||
self.assertEqual(config.language_code, "ru")
|
||||
self.assertEqual(config.request_timeout_seconds, 120)
|
||||
|
||||
def test_elevenlabs_env_overrides(self) -> None:
|
||||
env = {
|
||||
"ELEVENLABS_API_KEY": "env-key",
|
||||
"ELEVENLABS_MODEL_ID": "scribe_v2",
|
||||
"ELEVENLABS_LANGUAGE_CODE": "en",
|
||||
"ELEVENLABS_REQUEST_TIMEOUT_SECONDS": "45",
|
||||
}
|
||||
with patch.dict("os.environ", env, clear=True):
|
||||
config = _parse_elevenlabs_config({"api_key": "config-key"})
|
||||
|
||||
self.assertEqual(config.api_key, "env-key")
|
||||
self.assertEqual(config.language_code, "en")
|
||||
self.assertEqual(config.request_timeout_seconds, 45)
|
||||
|
||||
|
||||
class ConfigAiTests(unittest.TestCase):
|
||||
def test_ai_config_parses_both_providers(self) -> None:
|
||||
with patch.dict("os.environ", {}, clear=True):
|
||||
config = _parse_ai_config(
|
||||
{
|
||||
"glm": {"api_key": "glm-key", "model": "glm-model"},
|
||||
"deepseek": {"api_key": "ds-key", "model": "ds-model"},
|
||||
}
|
||||
)
|
||||
|
||||
self.assertEqual(config.glm.api_key, "glm-key")
|
||||
self.assertEqual(config.glm.model, "glm-model")
|
||||
self.assertEqual(config.deepseek.api_key, "ds-key")
|
||||
self.assertEqual(config.deepseek.model, "ds-model")
|
||||
|
||||
def test_ai_provider_env_overrides(self) -> None:
|
||||
env = {
|
||||
"GLM_API_KEY": "env-glm",
|
||||
"GLM_MODEL": "env-glm-model",
|
||||
"DEEPSEEK_API_KEY": "env-ds",
|
||||
"DEEPSEEK_MODEL": "env-ds-model",
|
||||
}
|
||||
with patch.dict("os.environ", env, clear=True):
|
||||
config = _parse_ai_config({})
|
||||
|
||||
self.assertEqual(config.glm.api_key, "env-glm")
|
||||
self.assertEqual(config.glm.model, "env-glm-model")
|
||||
self.assertEqual(config.deepseek.api_key, "env-ds")
|
||||
self.assertEqual(config.deepseek.model, "env-ds-model")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user