Co-authored-by: Alexis Tacnet <alexis@mistral.ai> Co-authored-by: Clément Drouin <clement.drouin@mistral.ai> Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com> Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com> Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai> Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai> Co-authored-by: Quentin <quentin.torroba@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: p.vezia <166131032+le-codeur-rapide@users.noreply.github.com> Co-authored-by: Hiba Chaabnia <Hiba-Chaabnia@users.noreply.github.com> Co-authored-by: Nikhil Bhima <nikhilbhima@users.noreply.github.com> Co-authored-by: Nkipohcs <Nkipohcs@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
62 lines
1.9 KiB
Python
62 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
|
|
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.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
|