finish app develop
This commit is contained in:
47
tests/test_config.py
Normal file
47
tests/test_config.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pathlib import Path
|
||||
|
||||
from app.config import load_api_config
|
||||
|
||||
|
||||
def test_load_api_config_selects_default_provider(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "api_config.yaml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
default_provider: intranet
|
||||
providers:
|
||||
intranet:
|
||||
api_key: EMPTY
|
||||
base_url: http://model.local/v1
|
||||
max_tokens: 1024
|
||||
model: qwen3-coder
|
||||
temperature: 0.2
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
settings = load_api_config(config_path)
|
||||
|
||||
assert settings.provider_name == "intranet"
|
||||
assert settings.provider.model == "qwen3-coder"
|
||||
assert settings.provider.chat_completions_url == "http://model.local/v1/chat/completions"
|
||||
|
||||
|
||||
def test_load_api_config_accepts_full_chat_completions_url(tmp_path: Path) -> None:
|
||||
config_path = tmp_path / "api_config.yaml"
|
||||
config_path.write_text(
|
||||
"""
|
||||
default_provider: deepseek
|
||||
providers:
|
||||
deepseek:
|
||||
api_key: key
|
||||
base_url: https://api.deepseek.com/v1/chat/completions
|
||||
max_tokens: 4000
|
||||
model: deepseek-chat
|
||||
temperature: 0.7
|
||||
""".strip(),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
settings = load_api_config(config_path, provider_name="deepseek")
|
||||
|
||||
assert settings.provider.chat_completions_url == "https://api.deepseek.com/v1/chat/completions"
|
||||
Reference in New Issue
Block a user