Co-authored-by: Antoine <33425718+anth2o@users.noreply.github.com> Co-authored-by: Bastien <bastien.baret@gmail.com> Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai> Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com> Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@mistral.ai> Co-authored-by: Robin Gullo <robin.gullo@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pexpect
|
|
import pytest
|
|
|
|
from tests.e2e.common import (
|
|
SpawnedVibeProcessFixture,
|
|
ansi_tolerant_pattern,
|
|
send_ctrl_c_until_quit_confirmation,
|
|
wait_for_main_screen,
|
|
wait_for_request_count,
|
|
)
|
|
from tests.e2e.mock_server import StreamingMockServer
|
|
|
|
|
|
@pytest.mark.timeout(15)
|
|
def test_spawn_cli_to_send_and_receive_message(
|
|
streaming_mock_server: StreamingMockServer,
|
|
setup_e2e_env: None,
|
|
e2e_workdir: Path,
|
|
spawned_vibe_process: SpawnedVibeProcessFixture,
|
|
) -> None:
|
|
with spawned_vibe_process(e2e_workdir) as (child, captured):
|
|
wait_for_main_screen(child, timeout=15)
|
|
child.send("Greet")
|
|
child.send("\r")
|
|
|
|
wait_for_request_count(
|
|
lambda: len(streaming_mock_server.requests), expected_count=1, timeout=10
|
|
)
|
|
child.expect(ansi_tolerant_pattern("Hello from mock server"), timeout=10)
|
|
|
|
send_ctrl_c_until_quit_confirmation(child, captured, timeout=5)
|
|
child.expect(pexpect.EOF, timeout=10)
|
|
|
|
output = captured.getvalue()
|
|
assert "Welcome to Mistral Vibe" not in output
|
|
|
|
request_payload = streaming_mock_server.requests[-1]
|
|
assert request_payload.get("stream") is True
|
|
assert request_payload.get("model") == "mock-model"
|
|
stream_options = request_payload.get("stream_options")
|
|
assert stream_options is not None
|
|
assert stream_options.get("include_usage") is True
|
|
messages = request_payload.get("messages")
|
|
assert messages is not None
|
|
assert any(
|
|
message.get("role") == "user" and message.get("content") == "Greet"
|
|
for message in messages
|
|
)
|