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>
This commit is contained in:
Clément Drouin 2026-06-19 11:01:24 +02:00 committed by GitHub
parent 564a14365e
commit 6bedf271ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
223 changed files with 10533 additions and 6947 deletions

View file

@ -0,0 +1,79 @@
from __future__ import annotations
from pathlib import Path
import pytest
import tomli_w
from vibe.core.config import DEFAULT_THEME
from vibe.core.trusted_folders import trusted_folders_manager
from vibe.setup.update_prompt import load_update_prompt_theme
def _write_config(path: Path, **data: object) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(tomli_w.dumps(data), encoding="utf-8")
def test_env_theme_overrides_config_file(tmp_path: Path) -> None:
config_file = tmp_path / "config.toml"
_write_config(config_file, theme="textual-light")
theme = load_update_prompt_theme(
environ={"VIBE_THEME": "dracula"}, config_file=config_file
)
assert theme == "dracula"
def test_config_theme_is_used_when_env_theme_is_missing(tmp_path: Path) -> None:
config_file = tmp_path / "config.toml"
_write_config(config_file, theme="textual-light")
theme = load_update_prompt_theme(environ={}, config_file=config_file)
assert theme == "textual-light"
def test_invalid_theme_falls_back_to_default(tmp_path: Path) -> None:
config_file = tmp_path / "config.toml"
_write_config(config_file, theme="unknown-theme")
theme = load_update_prompt_theme(environ={}, config_file=config_file)
assert theme == DEFAULT_THEME
def test_invalid_env_theme_does_not_fall_through_to_config(tmp_path: Path) -> None:
config_file = tmp_path / "config.toml"
_write_config(config_file, theme="dracula")
theme = load_update_prompt_theme(
environ={"VIBE_THEME": "unknown-theme"}, config_file=config_file
)
assert theme == DEFAULT_THEME
def test_trust_aware_config_source_ignores_untrusted_project_theme(
config_dir: Path, tmp_working_directory: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.delenv("VIBE_HOME", raising=False)
_write_config(config_dir / "config.toml", theme="textual-light")
_write_config(tmp_working_directory / ".vibe" / "config.toml", theme="dracula")
theme = load_update_prompt_theme(environ={})
assert theme == "textual-light"
def test_trust_aware_config_source_can_use_trusted_project_theme(
tmp_working_directory: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.delenv("VIBE_HOME", raising=False)
_write_config(tmp_working_directory / ".vibe" / "config.toml", theme="dracula")
trusted_folders_manager.add_trusted(tmp_working_directory)
theme = load_update_prompt_theme(environ={})
assert theme == "dracula"