Skip to content

Commit 2272ae6

Browse files
committed
test: Add integration tests
1 parent 1f0b3c0 commit 2272ae6

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

integrations/mistral/tests/test_mistral_chat_generator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,24 @@ def test_live_run_with_mixed_tools(self, mixed_tools):
850850
assert tool_call.arguments["city"] in ["Paris", "Berlin"]
851851
assert tool_call_message.meta["finish_reason"] == "tool_calls"
852852

853+
@pytest.mark.skipif(
854+
not os.environ.get("MISTRAL_API_KEY", None),
855+
reason="Export an env var called MISTRAL_API_KEY containing the Mistral API key to run this test.",
856+
)
857+
@pytest.mark.integration
858+
def test_live_run_with_reasoning(self):
859+
chat_messages = [ChatMessage.from_user("If x + 3 = 7, what is x?")]
860+
component = MistralChatGenerator(generation_kwargs={"reasoning_effort": "high"})
861+
results = component.run(chat_messages)
862+
863+
assert len(results["replies"]) == 1
864+
message: ChatMessage = results["replies"][0]
865+
assert message.reasoning is not None
866+
assert message.reasoning.reasoning_text
867+
assert message.text
868+
assert "4" in message.text
869+
assert message.meta["finish_reason"] == "stop"
870+
853871

854872
@pytest.fixture
855873
def mock_reasoning_response():

integrations/mistral/tests/test_mistral_chat_generator_async.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,25 @@ async def callback(chunk: StreamingChunk):
258258
assert tool_call.arguments == {"city": "Paris"}
259259
assert tool_message.meta["finish_reason"] == "tool_calls"
260260

261+
@pytest.mark.skipif(
262+
not os.environ.get("MISTRAL_API_KEY", None),
263+
reason="Export an env var called MISTRAL_API_KEY containing the Mistral API key to run this test.",
264+
)
265+
@pytest.mark.integration
266+
@pytest.mark.asyncio
267+
async def test_live_run_async_with_reasoning(self):
268+
chat_messages = [ChatMessage.from_user("If x + 3 = 7, what is x?")]
269+
component = MistralChatGenerator(generation_kwargs={"reasoning_effort": "high"})
270+
results = await component.run_async(chat_messages)
271+
272+
assert len(results["replies"]) == 1
273+
message: ChatMessage = results["replies"][0]
274+
assert message.reasoning is not None
275+
assert message.reasoning.reasoning_text
276+
assert message.text
277+
assert "4" in message.text
278+
assert message.meta["finish_reason"] == "stop"
279+
261280
@pytest.mark.asyncio
262281
async def test_run_async_with_reasoning(self, chat_messages, monkeypatch):
263282
monkeypatch.setenv("MISTRAL_API_KEY", "fake-api-key")

0 commit comments

Comments
 (0)