mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
test: add non-streaming regression test for custom api_base suffix
Addresses reviewer feedback: the original test only covered the streaming path (stream=True → :streamRawPredict). This adds a parallel test for the non-streaming path (stream=False → :rawPredict) to ensure both endpoint suffixes are appended when a custom api_base is provided. Ref: #25748
This commit is contained in:
parent
750da1309f
commit
9bed91199d
1 changed files with 42 additions and 0 deletions
|
|
@ -336,3 +336,45 @@ def test_validate_environment_custom_api_base_calls_get_complete_vertex_url():
|
|||
assert mock_get_url.call_args.kwargs["custom_api_base"] == custom_base
|
||||
# The returned api_base should have the suffix
|
||||
assert api_base == f"{custom_base}:streamRawPredict"
|
||||
|
||||
|
||||
def test_validate_environment_custom_api_base_non_streaming():
|
||||
"""Regression test for #25748 (non-streaming path): custom api_base must
|
||||
still go through get_complete_vertex_url so that :rawPredict is appended."""
|
||||
config = VertexAIPartnerModelsAnthropicMessagesConfig()
|
||||
headers = {}
|
||||
litellm_params = {
|
||||
"vertex_ai_project": "test-project",
|
||||
"vertex_ai_location": "us-central1",
|
||||
"vertex_credentials": "{}",
|
||||
}
|
||||
custom_base = (
|
||||
"https://aiplatform.us.rep.googleapis.com/v1/projects/my-project"
|
||||
"/locations/us/publishers/anthropic/models/claude-sonnet-4-5@20250929"
|
||||
)
|
||||
optional_params = {"stream": False}
|
||||
|
||||
with patch.object(
|
||||
config, "_ensure_access_token", return_value=("token", "test-project")
|
||||
), patch.object(
|
||||
config,
|
||||
"get_complete_vertex_url",
|
||||
return_value=f"{custom_base}:rawPredict",
|
||||
) as mock_get_url:
|
||||
updated_headers, api_base = config.validate_anthropic_messages_environment(
|
||||
headers=headers,
|
||||
model="claude-sonnet-4-5@20250929",
|
||||
messages=[],
|
||||
optional_params=optional_params,
|
||||
litellm_params=litellm_params,
|
||||
api_base=custom_base,
|
||||
)
|
||||
|
||||
# get_complete_vertex_url MUST be called even with a custom api_base
|
||||
assert mock_get_url.called, (
|
||||
"get_complete_vertex_url should be called when api_base is provided "
|
||||
"so that the endpoint suffix (:rawPredict) is appended"
|
||||
)
|
||||
assert mock_get_url.call_args.kwargs["custom_api_base"] == custom_base
|
||||
# The returned api_base should have the non-streaming suffix
|
||||
assert api_base == f"{custom_base}:rawPredict"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue