vibe/tests/cli/test_typing_debounce.py
Mathias Gesbert 228f3c65a9
v2.10.0 (#697)
Co-authored-by: Clément Drouin <clement.drouin@mistral.ai>
Co-authored-by: Corentin André <corentin.andre@mistral.ai>
Co-authored-by: Guillaume LE GOFF <guillaume.lgf@gmail.com>
Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
Co-authored-by: Maxime Dolores <maxime.dolores@ext.mistral.ai>
Co-authored-by: Nelson PROIA <144663685+Nelson-PROIA@users.noreply.github.com>
Co-authored-by: Peter Evers <pevers90@gmail.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Quentin <quentin.torroba@mistral.ai>
Co-authored-by: Vincent G <10739306+VinceOPS@users.noreply.github.com>
Co-authored-by: MichisGitIsKing <MichisGitIsKing@users.noreply.github.com>
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
2026-05-19 11:56:25 +02:00

35 lines
1.2 KiB
Python

from __future__ import annotations
import pytest
from vibe.cli.textual_ui.app import _TYPING_DEBOUNCE_ENV_VAR, _resolve_typing_debounce_s
_TEST_DEFAULT_DEBOUNCE_MS = 1000
@pytest.fixture(autouse=True)
def _restore_default_debounce(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(
"vibe.cli.textual_ui.app._DEFAULT_TYPING_DEBOUNCE_MS", _TEST_DEFAULT_DEBOUNCE_MS
)
class TestTypingDebounceEnvVar:
@pytest.mark.parametrize(
("env_value", "expected_s"), [("500", 0.5), ("2000", 2.0), ("0", 0.0)]
)
def test_env_var_override(
self, env_value: str, expected_s: float, monkeypatch: pytest.MonkeyPatch
):
monkeypatch.setenv(_TYPING_DEBOUNCE_ENV_VAR, env_value)
assert _resolve_typing_debounce_s() == expected_s
@pytest.mark.parametrize("env_value", [None, "not-a-number", "-100"])
def test_falls_back_to_default(
self, env_value: str | None, monkeypatch: pytest.MonkeyPatch
):
if env_value is None:
monkeypatch.delenv(_TYPING_DEBOUNCE_ENV_VAR, raising=False)
else:
monkeypatch.setenv(_TYPING_DEBOUNCE_ENV_VAR, env_value)
assert _resolve_typing_debounce_s() == _TEST_DEFAULT_DEBOUNCE_MS / 1000