forked from innovacion/searchbox
Add test coverage
This commit is contained in:
@@ -6,7 +6,7 @@ from vector_search_mcp.engine.base_engine import BaseEngine
|
||||
from vector_search_mcp.models import Condition, Match, MatchAny, SearchRow
|
||||
|
||||
|
||||
class MockEngine(BaseEngine[dict[str, Any], str]):
|
||||
class MockEngine(BaseEngine[dict[str, Any], str, dict]):
|
||||
"""Mock engine for testing BaseEngine abstract functionality"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -50,6 +50,22 @@ class MockEngine(BaseEngine[dict[str, Any], str]):
|
||||
"score_2": 0.75,
|
||||
}
|
||||
|
||||
async def create_index(self, name: str, size: int) -> bool:
|
||||
"""Mock implementation of create_index"""
|
||||
return True
|
||||
|
||||
def transform_chunk(self, chunk) -> dict:
|
||||
"""Mock implementation of transform_chunk"""
|
||||
return {
|
||||
"id": chunk.id,
|
||||
"vector": chunk.vector,
|
||||
"payload": chunk.payload.model_dump()
|
||||
}
|
||||
|
||||
async def run_upload_chunk(self, index_name: str, chunk: dict) -> bool:
|
||||
"""Mock implementation of run_upload_chunk"""
|
||||
return True
|
||||
|
||||
|
||||
class TestBaseEngine:
|
||||
"""Test suite for BaseEngine abstract class"""
|
||||
@@ -66,6 +82,9 @@ class TestBaseEngine:
|
||||
"transform_conditions",
|
||||
"transform_response",
|
||||
"run_similarity_query",
|
||||
"create_index",
|
||||
"transform_chunk",
|
||||
"run_upload_chunk",
|
||||
}
|
||||
assert abstract_methods == expected_methods
|
||||
|
||||
@@ -209,13 +228,13 @@ class TestBaseEngine:
|
||||
assert all(isinstance(item, SearchRow) for item in response_result)
|
||||
|
||||
|
||||
class IncompleteEngine(BaseEngine[str, int]):
|
||||
class IncompleteEngine(BaseEngine[str, int, str]):
|
||||
"""Incomplete engine implementation for testing abstract method enforcement"""
|
||||
|
||||
def transform_conditions(self, conditions: list[Condition] | None) -> int | None:
|
||||
return None
|
||||
|
||||
# Missing transform_response and run_similarity_query
|
||||
# Missing transform_response, run_similarity_query, create_index, transform_chunk, run_upload_chunk
|
||||
|
||||
|
||||
class TestAbstractMethodEnforcement:
|
||||
|
||||
Reference in New Issue
Block a user