Files
Claude-Code-Workflow/codex-lens/tests/test_watcher/conftest.py
catlog22 520f2d26f2 feat(codex-lens): add unified reranker architecture and file watcher
Unified Reranker Architecture:
- Add BaseReranker ABC with factory pattern
- Implement 4 backends: ONNX (default), API, LiteLLM, Legacy
- Add .env configuration parsing for API credentials
- Migrate from sentence-transformers to optimum+onnxruntime

File Watcher Module:
- Add real-time file system monitoring with watchdog
- Implement IncrementalIndexer for single-file updates
- Add WatcherManager with signal handling and graceful shutdown
- Add 'codexlens watch' CLI command
- Event filtering, debouncing, and deduplication
- Thread-safe design with proper resource cleanup

Tests: 16 watcher tests + 5 reranker test files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 13:23:52 +08:00

44 lines
1.2 KiB
Python

"""Fixtures for watcher tests."""
from __future__ import annotations
import tempfile
from pathlib import Path
from typing import Generator
import pytest
@pytest.fixture
def temp_project() -> Generator[Path, None, None]:
"""Create a temporary project directory with sample files."""
with tempfile.TemporaryDirectory() as tmpdir:
project = Path(tmpdir)
# Create sample Python file
py_file = project / "main.py"
py_file.write_text("def hello():\n print('Hello')\n")
# Create sample JavaScript file
js_file = project / "app.js"
js_file.write_text("function greet() {\n console.log('Hi');\n}\n")
# Create subdirectory with file
sub_dir = project / "src"
sub_dir.mkdir()
(sub_dir / "utils.py").write_text("def add(a, b):\n return a + b\n")
# Create ignored directory
git_dir = project / ".git"
git_dir.mkdir()
(git_dir / "config").write_text("[core]\n")
yield project
@pytest.fixture
def watcher_config():
"""Create default watcher configuration."""
from codexlens.watcher import WatcherConfig
return WatcherConfig(debounce_ms=100) # Short debounce for tests