vibe/tests/agent_loop/e2e/conftest.py
Laure Hugo e607ccbb00
v2.18.0 (#843)
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Cyprien <courtot.c@gmail.com>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com>
Co-authored-by: Paul VEZIA <166131032+le-codeur-rapide@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: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: josephine-delas <57808586+josephine-delas@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
2026-06-25 16:08:45 +02:00

50 lines
1.7 KiB
Python

from __future__ import annotations
from collections.abc import Iterator
from typing import Any
import pytest
import respx
from tests.agent_loop.e2e.providers import MistralAPI
from tests.conftest import build_test_agent_loop, build_test_vibe_config
from vibe.core.agent_loop import AgentLoop
from vibe.core.agents.models import BuiltinAgentName
from vibe.core.config import VibeConfig
from vibe.core.llm.backend.factory import BACKEND_FACTORY
@pytest.fixture(autouse=True)
def _git_offline(monkeypatch: pytest.MonkeyPatch) -> None:
# Restrict git to the local file protocol so no test can fetch/push over the
# network, even if a remote is misconfigured to a real URL.
monkeypatch.setenv("GIT_ALLOW_PROTOCOL", "file")
@pytest.fixture
def mock_mistral() -> Iterator[respx.MockRouter]:
with respx.mock(base_url=MistralAPI.base_url, assert_all_called=False) as router:
yield router
@pytest.fixture
def mistral_api(mock_mistral: respx.MockRouter) -> MistralAPI:
api = MistralAPI()
api.setup_router(mock_mistral)
return api
def build_e2e_agent_loop(
*, config: VibeConfig | None = None, enable_streaming: bool = False, **kwargs: Any
) -> AgentLoop:
resolved_config = config or build_test_vibe_config()
provider = resolved_config.providers[0]
# todo now we use build_test_agent_loop for the fake mcp registry.
# Maybe mock http tool calls and instantiate a real registry later for more coverage
return build_test_agent_loop(
config=resolved_config,
agent_name=kwargs.pop("agent_name", BuiltinAgentName.AUTO_APPROVE),
backend=BACKEND_FACTORY[provider.backend](provider=provider),
enable_streaming=enable_streaming,
**kwargs,
)