fix: validate named custom provider endpoints
This commit is contained in:
@@ -79,6 +79,50 @@ def test_custom_provider_fallback_uses_model_extra_without_pydantic_warnings() -
|
||||
assert config.get_provider_name() == "my-company-api"
|
||||
|
||||
|
||||
def test_dynamic_custom_provider_prefix_matches_camel_case_key() -> None:
|
||||
config = Config.model_validate({
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"provider": "auto",
|
||||
"model": "companyProxy/gpt-4o-mini",
|
||||
}
|
||||
},
|
||||
"providers": {
|
||||
"otherProxy": {
|
||||
"apiBase": "https://other.example.test/v1",
|
||||
},
|
||||
"companyProxy": {
|
||||
"apiBase": "https://company.example.test/v1",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
assert config.get_provider_name() == "companyProxy"
|
||||
assert config.get_api_base() == "https://company.example.test/v1"
|
||||
|
||||
|
||||
def test_dynamic_custom_provider_prefix_does_not_fall_through_when_base_missing() -> None:
|
||||
config = Config.model_validate({
|
||||
"agents": {
|
||||
"defaults": {
|
||||
"provider": "auto",
|
||||
"model": "companyProxy/gpt-4o-mini",
|
||||
}
|
||||
},
|
||||
"providers": {
|
||||
"otherProxy": {
|
||||
"apiBase": "https://other.example.test/v1",
|
||||
},
|
||||
"companyProxy": {
|
||||
"apiKey": "sk-company",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
assert config.get_provider_name() == "companyProxy"
|
||||
assert config.get_api_base() is None
|
||||
|
||||
|
||||
def test_legacy_defaults_config_without_presets_still_resolves() -> None:
|
||||
config = Config.model_validate({
|
||||
"agents": {
|
||||
|
||||
Reference in New Issue
Block a user