v2.4.1 (#475)
Co-authored-by: Quentin Torroba <quentin.torroba@mistral.ai> Co-authored-by: Clement Sirieix <clem.sirieix@gmail.com> Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
dd372ce494
commit
e9428bce23
54 changed files with 877 additions and 362 deletions
|
|
@ -4,8 +4,12 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from vibe.core.paths.config_paths import CONFIG_FILE
|
||||
from vibe.core.paths.global_paths import GLOBAL_CONFIG_FILE, VIBE_HOME
|
||||
from vibe.core.config.harness_files import (
|
||||
HarnessFilesManager,
|
||||
init_harness_files_manager,
|
||||
reset_harness_files_manager,
|
||||
)
|
||||
from vibe.core.paths import VIBE_HOME
|
||||
from vibe.core.trusted_folders import trusted_folders_manager
|
||||
|
||||
|
||||
|
|
@ -21,11 +25,18 @@ class TestResolveConfigFile:
|
|||
|
||||
monkeypatch.setattr(trusted_folders_manager, "is_trusted", lambda _: True)
|
||||
|
||||
assert CONFIG_FILE.path == local_config
|
||||
assert CONFIG_FILE.path.is_file()
|
||||
assert CONFIG_FILE.path.read_text(encoding="utf-8") == 'active_model = "test"'
|
||||
reset_harness_files_manager()
|
||||
init_harness_files_manager("user", "project")
|
||||
from vibe.core.config.harness_files import get_harness_files_manager
|
||||
|
||||
def test_resolves_local_config_when_exists_and_folder_is_not_trusted(
|
||||
mgr = get_harness_files_manager()
|
||||
resolved = mgr.config_file
|
||||
assert resolved is not None
|
||||
assert resolved == local_config
|
||||
assert resolved.is_file()
|
||||
assert resolved.read_text(encoding="utf-8") == 'active_model = "test"'
|
||||
|
||||
def test_resolves_global_config_when_folder_is_not_trusted(
|
||||
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
|
@ -34,7 +45,12 @@ class TestResolveConfigFile:
|
|||
local_config = local_config_dir / "config.toml"
|
||||
local_config.write_text('active_model = "test"', encoding="utf-8")
|
||||
|
||||
assert CONFIG_FILE.path == GLOBAL_CONFIG_FILE.path
|
||||
reset_harness_files_manager()
|
||||
init_harness_files_manager("user", "project")
|
||||
from vibe.core.config.harness_files import get_harness_files_manager
|
||||
|
||||
mgr = get_harness_files_manager()
|
||||
assert mgr.config_file == VIBE_HOME.path / "config.toml"
|
||||
|
||||
def test_falls_back_to_global_config_when_local_missing(
|
||||
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
|
|
@ -43,7 +59,12 @@ class TestResolveConfigFile:
|
|||
# Ensure no local config exists
|
||||
assert not (tmp_path / ".vibe" / "config.toml").exists()
|
||||
|
||||
assert CONFIG_FILE.path == GLOBAL_CONFIG_FILE.path
|
||||
reset_harness_files_manager()
|
||||
init_harness_files_manager("user", "project")
|
||||
from vibe.core.config.harness_files import get_harness_files_manager
|
||||
|
||||
mgr = get_harness_files_manager()
|
||||
assert mgr.config_file == VIBE_HOME.path / "config.toml"
|
||||
|
||||
def test_respects_vibe_home_env_var(
|
||||
self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
|
|
@ -51,3 +72,11 @@ class TestResolveConfigFile:
|
|||
assert VIBE_HOME.path != tmp_path
|
||||
monkeypatch.setenv("VIBE_HOME", str(tmp_path))
|
||||
assert VIBE_HOME.path == tmp_path
|
||||
|
||||
def test_returns_none_when_no_sources(self) -> None:
|
||||
mgr = HarnessFilesManager(sources=())
|
||||
assert mgr.config_file is None
|
||||
|
||||
def test_user_only_returns_global_config(self) -> None:
|
||||
mgr = HarnessFilesManager(sources=("user",))
|
||||
assert mgr.config_file == VIBE_HOME.path / "config.toml"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue