Co-authored-by: Quentin Torroba <quentin.torroba@mistral.ai>
Co-authored-by: Michel Thomazo <michel.thomazo@mistral.ai>
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Vincent Guilloux <vincent.guilloux@mistral.ai>
Co-authored-by: Clément Siriex <clement.sirieix@mistral.ai>
Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai>
Co-authored-by: Nicolas Karolak <nicolas@karolak.fr>
This commit is contained in:
Mathias Gesbert 2026-02-11 18:17:30 +01:00 committed by GitHub
parent 9809cfc831
commit 51fecc67d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
176 changed files with 8652 additions and 4451 deletions

View file

@ -7,6 +7,18 @@ from typing import Any
import pytest
import tomli_w
from tests.cli.plan_offer.adapters.fake_whoami_gateway import FakeWhoAmIGateway
from tests.stubs.fake_backend import FakeBackend
from tests.update_notifier.adapters.fake_update_cache_repository import (
FakeUpdateCacheRepository,
)
from tests.update_notifier.adapters.fake_update_gateway import FakeUpdateGateway
from vibe.cli.plan_offer.ports.whoami_gateway import WhoAmIResponse
from vibe.cli.textual_ui.app import CORE_VERSION, VibeApp
from vibe.core.agent_loop import AgentLoop
from vibe.core.agents.models import BuiltinAgentName
from vibe.core.config import SessionLoggingConfig, VibeConfig
from vibe.core.llm.types import BackendLike
from vibe.core.paths import global_paths
from vibe.core.paths.config_paths import unlock_config_paths
@ -80,3 +92,101 @@ def _mock_platform(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.fixture(autouse=True)
def _mock_update_commands(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr("vibe.cli.update_notifier.update.UPDATE_COMMANDS", ["true"])
@pytest.fixture
def vibe_app() -> VibeApp:
return build_test_vibe_app()
@pytest.fixture
def agent_loop() -> AgentLoop:
return build_test_agent_loop()
@pytest.fixture
def vibe_config() -> VibeConfig:
return build_test_vibe_config()
def build_test_vibe_config(**kwargs) -> VibeConfig:
session_logging = kwargs.pop("session_logging", None)
resolved_session_logging = (
SessionLoggingConfig(enabled=False)
if session_logging is None
else session_logging
)
enable_update_checks = kwargs.pop("enable_update_checks", None)
resolved_enable_update_checks = (
False if enable_update_checks is None else enable_update_checks
)
return VibeConfig(
session_logging=resolved_session_logging,
enable_update_checks=resolved_enable_update_checks,
**kwargs,
)
def build_test_agent_loop(
*,
config: VibeConfig | None = None,
agent_name: str = BuiltinAgentName.DEFAULT,
backend: BackendLike | None = None,
enable_streaming: bool = False,
**kwargs,
) -> AgentLoop:
resolved_config = config or build_test_vibe_config()
return AgentLoop(
config=resolved_config,
agent_name=agent_name,
backend=backend or FakeBackend(),
enable_streaming=enable_streaming,
**kwargs,
)
def build_test_vibe_app(
*, config: VibeConfig | None = None, agent_loop: AgentLoop | None = None, **kwargs
) -> VibeApp:
app_config = config or build_test_vibe_config()
resolved_agent_loop = agent_loop or build_test_agent_loop(config=app_config)
update_notifier = kwargs.pop("update_notifier", None)
resolved_update_notifier = (
FakeUpdateGateway() if update_notifier is None else update_notifier
)
update_cache_repository = kwargs.pop("update_cache_repository", None)
resolved_update_cache_repository = (
FakeUpdateCacheRepository()
if update_cache_repository is None
else update_cache_repository
)
plan_offer_gateway = kwargs.pop("plan_offer_gateway", None)
resolved_plan_offer_gateway = (
FakeWhoAmIGateway(
WhoAmIResponse(
is_pro_plan=True,
advertise_pro_plan=False,
prompt_switching_to_pro_plan=False,
)
)
if plan_offer_gateway is None
else plan_offer_gateway
)
current_version = kwargs.pop("current_version", None)
resolved_current_version = (
CORE_VERSION if current_version is None else current_version
)
return VibeApp(
agent_loop=resolved_agent_loop,
current_version=resolved_current_version,
update_notifier=resolved_update_notifier,
update_cache_repository=resolved_update_cache_repository,
plan_offer_gateway=resolved_plan_offer_gateway,
initial_prompt=kwargs.pop("initial_prompt", None),
**kwargs,
)