mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-27 04:20:09 +00:00
- Update quality-gate.yml to only lint hanzo_mcp and tests directories
- Add ruff config to pyproject.toml:
- Exclude vscode-extension and node_modules
- Ignore lint rules that conflict with test patterns:
B023 (loop variable binding), B904 (raise from),
E741 (ambiguous vars), F401/F821/F841 (unused/undefined in tests)
- Apply per-file ignores for tests/ and __init__.py
- Apply ruff fixes for import sorting and format
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
"""E2E integration tests for LiteLLM providers.
|
|
|
|
These tests require real API keys and make actual API calls.
|
|
Only run in CI with proper secrets configured.
|
|
"""
|
|
|
|
import os
|
|
|
|
import litellm
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not os.environ.get("OPENAI_API_KEY"),
|
|
reason="OPENAI_API_KEY environment variable not set",
|
|
)
|
|
@pytest.mark.asyncio
|
|
async def test_litellm_openai_provider_integration():
|
|
"""Integration test: LiteLLM with real OpenAI provider."""
|
|
messages = [{"role": "user", "content": "Hello, how are you?"}]
|
|
|
|
try:
|
|
response = litellm.completion(
|
|
model="openai/gpt-3.5-turbo",
|
|
messages=messages,
|
|
)
|
|
assert response.choices[0].message.content is not None
|
|
except Exception as e:
|
|
pytest.skip(f"OpenAI API connection failed: {type(e).__name__} - {str(e)}")
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not os.environ.get("ANTHROPIC_API_KEY"),
|
|
reason="ANTHROPIC_API_KEY environment variable not set",
|
|
)
|
|
@pytest.mark.asyncio
|
|
async def test_litellm_anthropic_provider_integration():
|
|
"""Integration test: LiteLLM with real Anthropic provider."""
|
|
messages = [{"role": "user", "content": "Hello, how are you?"}]
|
|
|
|
try:
|
|
response = litellm.completion(
|
|
model="anthropic/claude-3-haiku-20240307",
|
|
messages=messages,
|
|
)
|
|
assert response.choices[0].message.content is not None
|
|
except Exception as e:
|
|
pytest.skip(f"Anthropic API connection failed: {type(e).__name__} - {str(e)}")
|