vibe/tests/core/test_vibe_config_schema.py
Clément Drouin 6bedf271ce
v2.17.0 (#822)
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Hdandria <henri.dandria@mistral.ai>
Co-authored-by: Ivana Dunisijevic <ivana.dunisijevic@mistral.ai>
Co-authored-by: Jean Burellier <sheplu@users.noreply.github.com>
Co-authored-by: Mathias Gesbert <mathias.gesbert@mistral.ai>
Co-authored-by: Mert Unsal <mert.unsal@mistral.ai>
Co-authored-by: Michel Thomazo <51709227+michelTho@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: Val <102326092+vdeva@users.noreply.github.com>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: renovate-mistral[bot] <253709520+renovate-mistral[bot]@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
2026-06-19 11:01:24 +02:00

64 lines
1.9 KiB
Python

from __future__ import annotations
from pathlib import Path
import pytest
from vibe.core.config._settings import VibeConfig
from vibe.core.config.vibe_schema import VibeConfigSchema
def test_vibe_config_schema_covers_all_vibe_config_fields() -> None:
legacy_fields = set(VibeConfig.model_fields.keys())
schema_fields = set(VibeConfigSchema.model_fields.keys())
missing = legacy_fields - schema_fields
assert not missing, (
f"VibeConfigSchema is missing {len(missing)} field(s) that exist in VibeConfig: "
f"{sorted(missing)}. "
f"When you add a new field to VibeConfig, also add it to VibeConfigSchema "
f"(vibe/core/config/vibe_schema.py) with the appropriate merge annotation."
)
@pytest.mark.asyncio
async def test_full_toml_to_vibe_config_schema(tmp_path: Path) -> None:
toml_path = tmp_path / "config.toml"
toml_path.write_text(
"""\
vim_keybindings = true
api_timeout = 300.0
api_retry_max_elapsed_time = 120.0
active_model = "codestral"
disabled_tools = ["bash"]
default_agent = "plan"
enabled_skills = ["search"]
enable_otel = true
[[models]]
alias = "codestral"
name = "codestral-latest"
provider = "mistral"
"""
)
from vibe.core.config.layers.user import UserConfigLayer
from vibe.core.config.orchestrator import ConfigOrchestrator
class VibeConfig(VibeConfigSchema):
pass
layer = UserConfigLayer(path=toml_path, name="user-toml")
orchestrator = await ConfigOrchestrator[VibeConfig].create(
schema=VibeConfig, layers=[layer]
)
config = orchestrator.config
assert config.vim_keybindings is True
assert config.api_timeout == 300.0
assert config.api_retry_max_elapsed_time == 120.0
assert config.active_model == "codestral"
assert config.models[0].alias == "codestral"
assert "bash" in config.disabled_tools
assert config.default_agent == "plan"
assert "search" in config.enabled_skills
assert config.enable_otel is True