Aggregates all v0.2.0 sprint work (GARAA-30 through GARAA-40) and fixes 2 integration tests that broke when the codebase went async (DSPyLLMAdapter and full pipeline tests now properly await coroutines). 277 tests pass (260 unit + 17 integration). Co-Authored-By: Paperclip <noreply@paperclip.ing>
30 lines
826 B
Python
30 lines
826 B
Python
"""Integration tests for DSPy adapters using DSPy mock LM."""
|
|
from __future__ import annotations
|
|
|
|
import dspy
|
|
import pytest
|
|
|
|
from prometheus.domain.entities import Prompt
|
|
from prometheus.infrastructure.llm_adapter import DSPyLLMAdapter
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_lm() -> dspy.LM:
|
|
"""Create a DSPy mock LM that returns predictable responses."""
|
|
lm = dspy.utils.DummyLM(
|
|
[
|
|
{"output": "Mock output response"},
|
|
]
|
|
)
|
|
return lm
|
|
|
|
|
|
class TestDSPyLLMAdapter:
|
|
@pytest.mark.asyncio
|
|
async def test_execute_returns_response(self, mock_lm: dspy.LM) -> None:
|
|
adapter = DSPyLLMAdapter(lm=mock_lm)
|
|
prompt = Prompt(text="Answer the question.")
|
|
result = await adapter.execute(prompt, "What is 2+2?")
|
|
assert isinstance(result, str)
|
|
assert len(result) > 0
|