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