25 lines
757 B
Python
25 lines
757 B
Python
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from application.config import settings
|
|
from application.llm_client import LLMClient
|
|
|
|
|
|
def test_llm_smoke_returns_ok():
|
|
if not settings.api.api_key:
|
|
pytest.skip("Sin API key configurada; se omite prueba de integración.")
|
|
client = LLMClient()
|
|
text, usage = client.chat_text(
|
|
messages=[{"role": "user", "content": "Responde exactamente: ok"}],
|
|
component="test_llm_smoke",
|
|
)
|
|
assert isinstance(text, str)
|
|
assert "ok" in text.lower()
|
|
if usage is not None:
|
|
assert isinstance(usage, dict)
|
|
# No todos los backends devuelven 'total_tokens'; validar presencia básica si existe
|
|
assert ("total_tokens" in usage) or ("prompt_tokens" in usage) or ("completion_tokens" in usage)
|
|
|
|
|