fix(kyma): fix test network calls and JSON indentation

- Replace live network test in test_kyma.py with mocked version using
  unittest.mock.patch — no real HTTP calls in unit test suite
- Add tests/llm_translation/test_kyma_live.py for live integration test
  (skips when KYMA_API_KEY not set, runs only in credentialed CI)
- Restore model_prices_and_context_window_backup.json to 4-space indent
  matching the upstream format — only kyma model entries are added

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sonpiaz 2026-04-10 18:37:46 -07:00
parent 04311e0bb9
commit d7ba39e567
3 changed files with 38366 additions and 38349 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,34 @@
"""
Live integration tests for Kyma API provider.
These tests make real network calls and require KYMA_API_KEY to be set.
They are intentionally placed here (llm_translation/) to be run only in
CI environments with credentials configured, not in the standard unit test suite.
"""
import os
import sys
import pytest
sys.path.insert(
0, os.path.abspath("../..")
) # Adds the parent directory to the system path
import litellm
KYMA_API_KEY = os.environ.get("KYMA_API_KEY")
@pytest.mark.skipif(not KYMA_API_KEY, reason="KYMA_API_KEY not set")
def test_kyma_live_completion():
"""Live test: call kyma/llama-3.3-70b and verify a valid response"""
response = litellm.completion(
model="kyma/llama-3.3-70b",
messages=[{"role": "user", "content": "Say 'test successful' and nothing else"}],
max_tokens=10,
)
assert response is not None
assert hasattr(response, "choices")
assert len(response.choices) > 0
assert response.choices[0].message.content is not None

View file

@ -1,14 +1,14 @@
"""
Tests for Kyma API provider configuration and integration.
Unit tests for Kyma API provider configuration and integration.
All network calls are mocked no real HTTP requests are made.
Live integration tests are in tests/llm_translation/test_kyma_live.py.
"""
import os
import sys
from unittest.mock import MagicMock, patch
try:
import pytest
except ImportError:
pytest = None
import pytest
# Add workspace to path
workspace_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../.."))
@ -18,7 +18,7 @@ import litellm
class TestKymaProviderConfig:
"""Test Kyma API provider configuration"""
"""Test Kyma API provider configuration (unit tests, no network calls)"""
def test_kyma_in_provider_list(self):
"""Test that kyma is in the provider list"""
@ -73,46 +73,29 @@ class TestKymaProviderConfig:
assert len(router.model_list) == 1
assert router.model_list[0]["model_name"] == "llama-3.3-70b"
def test_kyma_completion_skipped_without_key(self):
"""Test that completion is skipped when API key is not set"""
if not os.environ.get("KYMA_API_KEY"):
if pytest:
pytest.skip("KYMA_API_KEY not set")
return
def test_kyma_completion_mocked(self):
"""Test that completion routes correctly to kyma provider (mocked HTTP)"""
mock_message = MagicMock()
mock_message.content = "test successful"
mock_message.role = "assistant"
response = litellm.completion(
model="kyma/llama-3.3-70b",
messages=[{"role": "user", "content": "Say 'test successful' and nothing else"}],
max_tokens=10,
)
mock_choice = MagicMock()
mock_choice.message = mock_message
mock_choice.finish_reason = "stop"
mock_choice.index = 0
mock_response = MagicMock()
mock_response.choices = [mock_choice]
mock_response.model = "llama-3.3-70b"
with patch("litellm.main.completion", return_value=mock_response):
response = litellm.completion(
model="kyma/llama-3.3-70b",
messages=[{"role": "user", "content": "Say test successful"}],
max_tokens=10,
)
assert response is not None
assert hasattr(response, "choices")
assert len(response.choices) > 0
assert response.choices[0].message.content is not None
if __name__ == "__main__":
print("Testing Kyma API Provider...")
test_config = TestKymaProviderConfig()
print("\n1. Testing provider in list...")
test_config.test_kyma_in_provider_list()
print(" OK kyma in provider list")
print("\n2. Testing JSON config...")
test_config.test_kyma_json_config_exists()
print(" OK kyma JSON config loaded")
print("\n3. Testing provider resolution...")
test_config.test_kyma_provider_resolution()
print(" OK Provider resolution works")
print("\n4. Testing router configuration...")
test_config.test_kyma_router_config()
print(" OK Router configuration works")
print("\n" + "=" * 50)
print("All configuration tests passed!")
print("=" * 50)
assert response.choices[0].message.content == "test successful"