mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
Merge 0a8955e73a into e9b1c11098
This commit is contained in:
commit
01dc7ed54d
2 changed files with 11 additions and 9 deletions
|
|
@ -336,8 +336,6 @@ class ProxyInitializationHelpers:
|
|||
api_base = f"http://{host}:{port}"
|
||||
if isinstance(test, str):
|
||||
api_base = test
|
||||
else:
|
||||
raise ValueError("Invalid test value")
|
||||
client: Final = openai.OpenAI(api_key="My API Key", base_url=api_base)
|
||||
|
||||
response: Final = client.chat.completions.create(
|
||||
|
|
|
|||
|
|
@ -197,23 +197,27 @@ class TestProxyInitializationHelpers:
|
|||
mock_client.chat.completions.create.side_effect = [
|
||||
mock_response,
|
||||
mock_stream_response,
|
||||
mock_response,
|
||||
mock_stream_response,
|
||||
]
|
||||
|
||||
# Execute
|
||||
with pytest.raises(ValueError, match="Invalid test value"):
|
||||
ProxyInitializationHelpers._run_test_chat_completion(
|
||||
"localhost", 8000, "gpt-3.5-turbo", True
|
||||
)
|
||||
# The --test flag passes True; the helper must fall back to http://{host}:{port}
|
||||
ProxyInitializationHelpers._run_test_chat_completion(
|
||||
"localhost", 8000, "gpt-3.5-turbo", True
|
||||
)
|
||||
|
||||
# Test with valid string test value
|
||||
# Test with explicit string test value
|
||||
ProxyInitializationHelpers._run_test_chat_completion(
|
||||
"localhost", 8000, "gpt-3.5-turbo", "http://test-url"
|
||||
)
|
||||
|
||||
# Assert
|
||||
mock_openai.assert_called_once_with(
|
||||
api_key="My API Key", base_url="http://test-url"
|
||||
assert mock_openai.call_count == 2
|
||||
mock_openai.assert_any_call(
|
||||
api_key="My API Key", base_url="http://localhost:8000"
|
||||
)
|
||||
mock_openai.assert_any_call(api_key="My API Key", base_url="http://test-url")
|
||||
mock_client.chat.completions.create.assert_called()
|
||||
|
||||
def test_get_default_unvicorn_init_args(self):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue