v2.9.0 (#641)
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>
This commit is contained in:
parent
a83c81ecf5
commit
632ea8c032
253 changed files with 13965 additions and 2525 deletions
|
|
@ -1,21 +1,29 @@
|
|||
"""Tests for the Banner widget initial state with connectors/MCP."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
from unittest.mock import Mock
|
||||
|
||||
from vibe.cli.textual_ui.widgets.banner.banner import (
|
||||
Banner,
|
||||
BannerState,
|
||||
_connector_count,
|
||||
_pluralize,
|
||||
)
|
||||
from vibe.cli.textual_ui.widgets.banner.banner import Banner, BannerState, _pluralize
|
||||
from vibe.core.config import VibeConfig
|
||||
from vibe.core.config._settings import ModelConfig, ThinkingLevel
|
||||
from vibe.core.skills.manager import SkillManager
|
||||
from vibe.core.tools.connectors.connector_registry import ConnectorRegistry
|
||||
from vibe.core.tools.mcp.registry import MCPRegistry
|
||||
|
||||
|
||||
def _make_mock_config(
|
||||
active_model: str = "test-model", thinking: ThinkingLevel = "off"
|
||||
) -> Mock:
|
||||
config = Mock(spec=VibeConfig)
|
||||
config.active_model = active_model
|
||||
config.models = [active_model]
|
||||
config.mcp_servers = []
|
||||
config.connectors = []
|
||||
config.disable_welcome_banner_animation = False
|
||||
config.get_active_model.return_value = ModelConfig(
|
||||
name=active_model, provider="mistral", alias=active_model, thinking=thinking
|
||||
)
|
||||
return config
|
||||
|
||||
|
||||
class TestBannerInitialState:
|
||||
"""Test that Banner properly displays initial state including connectors/MCP."""
|
||||
|
||||
|
|
@ -28,54 +36,27 @@ class TestBannerInitialState:
|
|||
assert _pluralize(1, "MCP server") == "1 MCP server"
|
||||
assert _pluralize(2, "connector") == "2 connectors"
|
||||
|
||||
def test_connector_count_with_registry(self) -> None:
|
||||
"""Test _connector_count with a populated registry."""
|
||||
registry = Mock(spec=ConnectorRegistry)
|
||||
registry.connector_count = 3
|
||||
assert _connector_count(registry) == 3
|
||||
|
||||
def test_connector_count_without_registry(self) -> None:
|
||||
"""Test _connector_count with None registry."""
|
||||
assert _connector_count(None) == 0
|
||||
|
||||
def test_banner_initial_state_includes_connectors(self) -> None:
|
||||
"""Test that Banner._initial_state includes connector count."""
|
||||
config = Mock(spec=VibeConfig)
|
||||
config.active_model = "test-model"
|
||||
config.models = ["test-model"]
|
||||
config.mcp_servers = []
|
||||
config.disable_welcome_banner_animation = False
|
||||
|
||||
skill_manager = Mock(spec=SkillManager)
|
||||
skill_manager.custom_skills_count = 0
|
||||
|
||||
mcp_registry = Mock(spec=MCPRegistry)
|
||||
mcp_registry.count_loaded.return_value = 0
|
||||
|
||||
connector_registry = Mock(spec=ConnectorRegistry)
|
||||
connector_registry.connector_count = 5
|
||||
|
||||
banner = Banner(
|
||||
config=config,
|
||||
config=_make_mock_config(),
|
||||
skill_manager=skill_manager,
|
||||
mcp_registry=mcp_registry,
|
||||
connector_registry=connector_registry,
|
||||
connectors_count=5,
|
||||
)
|
||||
|
||||
assert banner._initial_state.active_model == "test-model"
|
||||
assert banner._initial_state.active_model == "test-model[off]"
|
||||
assert banner._initial_state.models_count == 1
|
||||
assert banner._initial_state.mcp_servers_count == 0
|
||||
assert banner._initial_state.connectors_count == 5
|
||||
assert banner._initial_state.skills_count == 0
|
||||
|
||||
def test_banner_initial_state_with_none_connector_registry(self) -> None:
|
||||
"""Test that Banner._initial_state handles None connector registry."""
|
||||
config = Mock(spec=VibeConfig)
|
||||
config.active_model = "test-model"
|
||||
config.models = ["test-model"]
|
||||
config.mcp_servers = []
|
||||
config.disable_welcome_banner_animation = False
|
||||
|
||||
def test_banner_initial_state_with_no_connectors(self) -> None:
|
||||
skill_manager = Mock(spec=SkillManager)
|
||||
skill_manager.custom_skills_count = 0
|
||||
|
||||
|
|
@ -83,23 +64,14 @@ class TestBannerInitialState:
|
|||
mcp_registry.count_loaded.return_value = 0
|
||||
|
||||
banner = Banner(
|
||||
config=config,
|
||||
config=_make_mock_config(),
|
||||
skill_manager=skill_manager,
|
||||
mcp_registry=mcp_registry,
|
||||
connector_registry=None,
|
||||
)
|
||||
|
||||
assert banner._initial_state.connectors_count == 0
|
||||
|
||||
def test_format_meta_counts_includes_connectors(self) -> None:
|
||||
"""Test that _format_meta_counts includes connector count when > 0."""
|
||||
# Test _format_meta_counts by directly calling it on a Banner instance
|
||||
config = Mock(spec=VibeConfig)
|
||||
config.active_model = "test-model"
|
||||
config.models = [] # Must be a list for len() to work
|
||||
config.mcp_servers = []
|
||||
config.disable_welcome_banner_animation = False
|
||||
|
||||
def test_banner_shows_thinking_level(self) -> None:
|
||||
skill_manager = Mock(spec=SkillManager)
|
||||
skill_manager.custom_skills_count = 0
|
||||
|
||||
|
|
@ -107,10 +79,24 @@ class TestBannerInitialState:
|
|||
mcp_registry.count_loaded.return_value = 0
|
||||
|
||||
banner = Banner(
|
||||
config=config,
|
||||
config=_make_mock_config(thinking="max"),
|
||||
skill_manager=skill_manager,
|
||||
mcp_registry=mcp_registry,
|
||||
)
|
||||
|
||||
assert banner._initial_state.active_model == "test-model[max]"
|
||||
|
||||
def test_format_meta_counts_includes_connectors(self) -> None:
|
||||
skill_manager = Mock(spec=SkillManager)
|
||||
skill_manager.custom_skills_count = 0
|
||||
|
||||
mcp_registry = Mock(spec=MCPRegistry)
|
||||
mcp_registry.count_loaded.return_value = 0
|
||||
|
||||
banner = Banner(
|
||||
config=_make_mock_config(),
|
||||
skill_manager=skill_manager,
|
||||
mcp_registry=mcp_registry,
|
||||
connector_registry=None,
|
||||
)
|
||||
|
||||
# Now test _format_meta_counts by setting state
|
||||
|
|
@ -134,34 +120,19 @@ class TestBannerInitialState:
|
|||
assert "5 skills" in result
|
||||
|
||||
|
||||
class TestBannerWithEnabledConnectors:
|
||||
"""Integration tests for Banner with EXPERIMENTAL_ENABLE_CONNECTORS=1."""
|
||||
|
||||
@patch("vibe.core.tools.connectors.connectors_enabled")
|
||||
def test_connectors_enabled_flag(self, mock_enabled: Mock) -> None:
|
||||
"""Test that connector count is read when enabled."""
|
||||
mock_enabled.return_value = True
|
||||
|
||||
config = Mock(spec=VibeConfig)
|
||||
config.active_model = "test-model"
|
||||
config.models = ["test-model"]
|
||||
config.mcp_servers = []
|
||||
config.disable_welcome_banner_animation = False
|
||||
|
||||
class TestBannerConnectorsCount:
|
||||
def test_connectors_count_passed_through(self) -> None:
|
||||
skill_manager = Mock(spec=SkillManager)
|
||||
skill_manager.custom_skills_count = 0
|
||||
|
||||
mcp_registry = Mock(spec=MCPRegistry)
|
||||
mcp_registry.count_loaded.return_value = 0
|
||||
|
||||
connector_registry = Mock(spec=ConnectorRegistry)
|
||||
connector_registry.connector_count = 5
|
||||
|
||||
banner = Banner(
|
||||
config=config,
|
||||
config=_make_mock_config(),
|
||||
skill_manager=skill_manager,
|
||||
mcp_registry=mcp_registry,
|
||||
connector_registry=connector_registry,
|
||||
connectors_count=5,
|
||||
)
|
||||
|
||||
assert banner._initial_state.connectors_count == 5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue