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>
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
import pytest
|
|
|
|
from tests.acp.conftest import _create_acp_agent
|
|
from vibe.acp.acp_agent_loop import VibeAcpAgentLoop
|
|
from vibe.acp.exceptions import InvalidRequestError
|
|
from vibe.core.agent_loop import AgentLoop
|
|
|
|
|
|
@pytest.fixture
|
|
def acp_agent_loop(backend) -> VibeAcpAgentLoop:
|
|
class PatchedAgentLoop(AgentLoop):
|
|
def __init__(self, *args, **kwargs) -> None:
|
|
super().__init__(*args, **{**kwargs, "backend": backend})
|
|
|
|
patch("vibe.acp.acp_agent_loop.AgentLoop", side_effect=PatchedAgentLoop).start()
|
|
return _create_acp_agent()
|
|
|
|
|
|
class TestTelemetryNotification:
|
|
@pytest.mark.asyncio
|
|
async def test_ignores_unknown_event_gracefully(
|
|
self,
|
|
acp_agent_loop: VibeAcpAgentLoop,
|
|
telemetry_events: list[dict[str, object]],
|
|
) -> None:
|
|
session = await acp_agent_loop.new_session(cwd=str(Path.cwd()), mcp_servers=[])
|
|
telemetry_events.clear()
|
|
|
|
await acp_agent_loop.ext_notification(
|
|
"telemetry/send",
|
|
{
|
|
"event": "vibe.unsupported_event",
|
|
"session_id": session.session_id,
|
|
"properties": {"context_type": "file"},
|
|
},
|
|
)
|
|
|
|
assert telemetry_events == []
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_raises_on_invalid_params(
|
|
self, acp_agent_loop: VibeAcpAgentLoop
|
|
) -> None:
|
|
with pytest.raises(InvalidRequestError):
|
|
await acp_agent_loop.ext_notification(
|
|
"telemetry/send",
|
|
{"event": "vibe.some_event"}, # missing session_id
|
|
)
|