vibe/tests/core/test_watcher.py
Mathias Gesbert e9a9217cc8
v2.7.4 (#579)
Co-authored-by: Clément Sirieix <clement.sirieix@mistral.ai>
Co-authored-by: Kim-Adeline Miguel <kimadeline.miguel@mistral.ai>
Co-authored-by: Lucas Marandat <31749711+lucasmrdt@users.noreply.github.com>
Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com>
Co-authored-by: Paul Cacheux <paul.cacheux@mistral.ai>
Co-authored-by: Peter Evers <pevers90@gmail.com>
Co-authored-by: Pierre Rossinès <pierre.rossines@mistral.ai>
Co-authored-by: Pierre Rossinès <pierre.rossines@protonmail.com>
Co-authored-by: Quentin <quentin.torroba@mistral.ai>
Co-authored-by: Simon Van de Kerckhove <simon.vandekerckhove@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: Mistral Vibe <vibe@mistral.ai>
2026-04-09 18:40:46 +02:00

50 lines
1.5 KiB
Python

from __future__ import annotations
from collections.abc import Generator
from pathlib import Path
import pytest
from vibe.core.autocompletion.file_indexer.watcher import WatchController
class TestWatchControllerIsWatching:
@pytest.fixture
def watch_dir(self, tmp_path: Path) -> Path:
return tmp_path / "watch"
@pytest.fixture
def watcher(self) -> Generator[WatchController, None, None]:
changes: list = []
controller = WatchController(on_changes=lambda root, c: changes.extend(c))
yield controller
controller.stop()
def test_is_watching_false_initially(self, watcher: WatchController) -> None:
assert watcher.is_watching is False
def test_is_watching_true_after_start(
self, watcher: WatchController, watch_dir: Path
) -> None:
watch_dir.mkdir()
watcher.start(watch_dir)
assert watcher.is_watching is True
def test_is_watching_false_after_stop(
self, watcher: WatchController, watch_dir: Path
) -> None:
watch_dir.mkdir()
watcher.start(watch_dir)
assert watcher.is_watching is True
watcher.stop()
assert watcher.is_watching is False
def test_is_watching_true_after_restart(
self, watcher: WatchController, watch_dir: Path
) -> None:
watch_dir.mkdir()
watcher.start(watch_dir)
watcher.stop()
assert watcher.is_watching is False
watcher.start(watch_dir)
assert watcher.is_watching is True