Files
hermes-agent/tests/workspace/test_base_indexer.py
T
alt-glitch 4921bad61f style(workspace): remove __future__ annotations, fix ty diagnostics
- Remove `from __future__ import annotations` from all new workspace files
- Convert TYPE_CHECKING imports to real imports in base.py (no circular deps)
- Quote self-referential forward ref in config.py model_validator
- Add null checks on spec.loader in plugin discovery to satisfy ty
2026-04-18 15:58:54 +05:30

47 lines
1.2 KiB
Python

# tests/workspace/test_base_indexer.py
"""Tests for BaseIndexer ABC contract."""
import pytest
from workspace.base import BaseIndexer
def test_base_indexer_cannot_be_instantiated_directly():
with pytest.raises(TypeError, match="abstract"):
BaseIndexer(None)
def test_concrete_subclass_must_implement_index_and_search():
class Incomplete(BaseIndexer):
def __init__(self, config):
pass
with pytest.raises(TypeError, match="abstract"):
Incomplete(None)
def test_concrete_subclass_with_both_methods_instantiates():
class Complete(BaseIndexer):
def __init__(self, config):
self._config = config
def index(self, *, progress=None):
from workspace.types import IndexSummary
return IndexSummary(
files_indexed=0,
files_skipped=0,
files_pruned=0,
files_errored=0,
chunks_created=0,
duration_seconds=0.0,
errors=[],
errors_truncated=False,
)
def search(self, query, *, limit=20, path_prefix=None, file_glob=None):
return []
indexer = Complete(None)
assert indexer.status() == {}