pageparse.ai / tests /test_search.py
Varun2007's picture
initial clean deployment commit with compilers
8c3e275
Raw
History Blame Contribute Delete
736 Bytes
from unittest.mock import MagicMock
import pytest
@pytest.fixture
def mock_search(monkeypatch: pytest.MonkeyPatch):
mock_store = MagicMock()
mock_store.get_records.return_value = [
{"id": 1, "type": "task", "content": "Buy milk", "priority": "high"},
{"id": 2, "type": "task", "content": "Walk dog", "priority": "low"},
]
monkeypatch.setattr("pageparse.search.Store", lambda: mock_store)
from pageparse.search import SemanticSearch
return SemanticSearch()
def test_search_returns_results(mock_search):
results = mock_search.search("milk")
assert len(results) == 2
def test_search_top_k(mock_search):
results = mock_search.search("milk", top_k=1)
assert len(results) == 1