70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
import pytest
|
|
|
|
from app.ai_provider.config.models import (
|
|
ModelConfig,
|
|
ProviderConfig,
|
|
derive_capabilities,
|
|
)
|
|
|
|
|
|
class TestModelConfig:
|
|
def test_minimal_config(self):
|
|
cfg = ModelConfig(
|
|
name="deepseek-v4-flash",
|
|
provider="deepseek",
|
|
model="deepseek-v4-flash",
|
|
format="openai",
|
|
)
|
|
assert cfg.name == "deepseek-v4-flash"
|
|
assert cfg.format == "openai"
|
|
assert not cfg.supports_vision # defaulted
|
|
|
|
def test_capability_override(self):
|
|
cfg = ModelConfig(
|
|
name="claude-sonnet",
|
|
provider="anthropic",
|
|
model="claude-sonnet-4-6",
|
|
format="anthropic",
|
|
supports_vision=True,
|
|
supports_tools=True,
|
|
)
|
|
assert cfg.supports_vision
|
|
assert cfg.supports_tools
|
|
|
|
def test_capability_auto_derive(self):
|
|
caps = derive_capabilities(provider="anthropic", model="claude-fable-5")
|
|
assert "chat" in caps
|
|
assert "tool_use" in caps
|
|
assert "vision" in caps
|
|
assert "reasoning" in caps
|
|
|
|
|
|
class TestProviderConfig:
|
|
def test_minimal(self):
|
|
cfg = ProviderConfig(
|
|
name="deepseek",
|
|
format="openai",
|
|
base_url_env="DEEPSEEK_BASE_URL",
|
|
api_key_env="DEEPSEEK_API_KEY",
|
|
)
|
|
assert cfg.name == "deepseek"
|
|
|
|
def test_with_parameter_mapping(self):
|
|
cfg = ProviderConfig(
|
|
name="deepseek",
|
|
format="openai",
|
|
base_url_env="DEEPSEEK_BASE_URL",
|
|
api_key_env="DEEPSEEK_API_KEY",
|
|
parameter_mappings={
|
|
"max_tokens": {"provider_param": "max_tokens"},
|
|
"temperature": {"provider_param": "temperature", "min": 0, "max": 2},
|
|
},
|
|
)
|
|
mapping = cfg.parameter_mappings["temperature"]
|
|
assert mapping.min == 0
|
|
assert mapping.max == 2
|
|
|
|
def test_format_validation(self):
|
|
with pytest.raises(ValueError, match="format"):
|
|
ProviderConfig(name="bad", format="unknown", base_url_env="X", api_key_env="Y")
|