mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
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>
This commit is contained in:
103
codex-lens/tests/test_watcher/test_events.py
Normal file
103
codex-lens/tests/test_watcher/test_events.py
Normal file
@@ -0,0 +1,103 @@
|
||||
"""Tests for watcher event types."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from codexlens.watcher import ChangeType, FileEvent, WatcherConfig, IndexResult, WatcherStats
|
||||
|
||||
|
||||
class TestChangeType:
|
||||
"""Tests for ChangeType enum."""
|
||||
|
||||
def test_change_types_exist(self):
|
||||
"""Verify all change types are defined."""
|
||||
assert ChangeType.CREATED.value == "created"
|
||||
assert ChangeType.MODIFIED.value == "modified"
|
||||
assert ChangeType.DELETED.value == "deleted"
|
||||
assert ChangeType.MOVED.value == "moved"
|
||||
|
||||
def test_change_type_count(self):
|
||||
"""Verify we have exactly 4 change types."""
|
||||
assert len(ChangeType) == 4
|
||||
|
||||
|
||||
class TestFileEvent:
|
||||
"""Tests for FileEvent dataclass."""
|
||||
|
||||
def test_create_event(self):
|
||||
"""Test creating a file event."""
|
||||
event = FileEvent(
|
||||
path=Path("/test/file.py"),
|
||||
change_type=ChangeType.CREATED,
|
||||
timestamp=time.time(),
|
||||
)
|
||||
assert event.path == Path("/test/file.py")
|
||||
assert event.change_type == ChangeType.CREATED
|
||||
assert event.old_path is None
|
||||
|
||||
def test_moved_event(self):
|
||||
"""Test creating a moved event with old_path."""
|
||||
event = FileEvent(
|
||||
path=Path("/test/new.py"),
|
||||
change_type=ChangeType.MOVED,
|
||||
timestamp=time.time(),
|
||||
old_path=Path("/test/old.py"),
|
||||
)
|
||||
assert event.old_path == Path("/test/old.py")
|
||||
|
||||
|
||||
class TestWatcherConfig:
|
||||
"""Tests for WatcherConfig dataclass."""
|
||||
|
||||
def test_default_config(self):
|
||||
"""Test default configuration values."""
|
||||
config = WatcherConfig()
|
||||
assert config.debounce_ms == 1000
|
||||
assert ".git" in config.ignored_patterns
|
||||
assert "node_modules" in config.ignored_patterns
|
||||
assert "__pycache__" in config.ignored_patterns
|
||||
assert config.languages is None
|
||||
|
||||
def test_custom_debounce(self):
|
||||
"""Test custom debounce setting."""
|
||||
config = WatcherConfig(debounce_ms=500)
|
||||
assert config.debounce_ms == 500
|
||||
|
||||
|
||||
class TestIndexResult:
|
||||
"""Tests for IndexResult dataclass."""
|
||||
|
||||
def test_default_result(self):
|
||||
"""Test default result values."""
|
||||
result = IndexResult()
|
||||
assert result.files_indexed == 0
|
||||
assert result.files_removed == 0
|
||||
assert result.symbols_added == 0
|
||||
assert result.errors == []
|
||||
|
||||
def test_custom_result(self):
|
||||
"""Test creating result with values."""
|
||||
result = IndexResult(
|
||||
files_indexed=5,
|
||||
files_removed=2,
|
||||
symbols_added=50,
|
||||
errors=["error1"],
|
||||
)
|
||||
assert result.files_indexed == 5
|
||||
assert result.files_removed == 2
|
||||
|
||||
|
||||
class TestWatcherStats:
|
||||
"""Tests for WatcherStats dataclass."""
|
||||
|
||||
def test_default_stats(self):
|
||||
"""Test default stats values."""
|
||||
stats = WatcherStats()
|
||||
assert stats.files_watched == 0
|
||||
assert stats.events_processed == 0
|
||||
assert stats.last_event_time is None
|
||||
assert stats.is_running is False
|
||||
Reference in New Issue
Block a user