~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: add missing interfaces and methods expected by tests (#3268)
LearningCircuit22a60ff50406
diff --git a/src/local_deep_research/advanced_search_system/constraint_checking/dual_confidence_checker.py b/src/local_deep_research/advanced_search_system/constraint_checking/dual_confidence_checker.pyindex 5c793b2528..a966ea3dcf 100644--- a/src/local_deep_research/advanced_search_system/constraint_checking/dual_confidence_checker.py+++ b/src/local_deep_research/advanced_search_system/constraint_checking/dual_confidence_checker.py@@ -80,6 +80,8 @@ class DualConfidenceChecker(BaseConstraintChecker):f"🚫 LLM pre-screen rejected {candidate.name}: {pre_screen_result['reason']}")return ConstraintCheckResult(+ candidate=candidate,+ constraint_scores={},should_reject=True,rejection_reason=pre_screen_result["reason"],total_score=0.0,diff --git a/tests/advanced_search_system/constraint_checking/test_dual_confidence_checker.py b/tests/advanced_search_system/constraint_checking/test_dual_confidence_checker.pyindex 191ed20619..0e2126a298 100644--- a/tests/advanced_search_system/constraint_checking/test_dual_confidence_checker.py+++ b/tests/advanced_search_system/constraint_checking/test_dual_confidence_checker.py@@ -326,7 +326,7 @@ class TestLLMPrescreenCandidate:)mock_model = Mock()- mock_model.generate.return_value = "85"+ mock_model.invoke.return_value = Mock(content="85")checker = DualConfidenceChecker(mock_model)candidate = MockCandidate(name="Good Answer")@@ -345,7 +345,7 @@ class TestLLMPrescreenCandidate:)mock_model = Mock()- mock_model.generate.return_value = "25"+ mock_model.invoke.return_value = Mock(content="25")checker = DualConfidenceChecker(mock_model)candidate = MockCandidate(name="Bad Answer")@@ -365,7 +365,7 @@ class TestLLMPrescreenCandidate:)mock_model = Mock()- mock_model.generate.return_value = "no score here"+ mock_model.invoke.return_value = Mock(content="no score here")checker = DualConfidenceChecker(mock_model)candidate = MockCandidate(name="Answer")@@ -384,7 +384,7 @@ class TestLLMPrescreenCandidate:)mock_model = Mock()- mock_model.generate.side_effect = Exception("LLM error")+ mock_model.invoke.side_effect = Exception("LLM error")checker = DualConfidenceChecker(mock_model)candidate = MockCandidate(name="Answer")@@ -491,7 +491,7 @@ class TestCheckCandidate:mock_model.invoke.return_value.content = ("POSITIVE: 0.8\nNEGATIVE: 0.1\nUNCERTAINTY: 0.1")- mock_model.generate.return_value = "75" # Pre-screen passes+ mock_model.invoke.return_value = Mock(content="75") # Pre-screen passesmock_gatherer = Mock(return_value=[{"text": "evidence"}])checker = DualConfidenceChecker(mock_model, evidence_gatherer=mock_gatherer@@ -516,7 +516,7 @@ class TestCheckCandidate:)mock_model = Mock()- mock_model.generate.return_value = "20" # Low quality score+ mock_model.invoke.return_value = Mock(content="20") # Low quality scorechecker = DualConfidenceChecker(mock_model)candidate = MockCandidate(name="Bad Answer")@@ -540,7 +540,7 @@ class TestCheckCandidate:mock_model.invoke.return_value.content = ("POSITIVE: 0.7\nNEGATIVE: 0.1\nUNCERTAINTY: 0.2")- mock_model.generate.return_value = "80"+ mock_model.invoke.return_value = Mock(content="80")mock_gatherer = Mock(return_value=[{"text": "evidence"}])checker = DualConfidenceChecker(mock_model, evidence_gatherer=mock_gatherer@@ -568,7 +568,7 @@ class TestCheckCandidate:mock_model.invoke.return_value.content = ("POSITIVE: 0.8\nNEGATIVE: 0.1\nUNCERTAINTY: 0.1")- mock_model.generate.return_value = "80"+ mock_model.invoke.return_value = Mock(content="80")mock_gatherer = Mock(return_value=[{"text": "evidence"}])checker = DualConfidenceChecker(mock_model, evidence_gatherer=mock_gatherer@@ -599,7 +599,7 @@ class TestCheckCandidate:mock_model.invoke.return_value.content = ("POSITIVE: 0.1\nNEGATIVE: 0.8\nUNCERTAINTY: 0.1")- mock_model.generate.return_value = "80"+ mock_model.invoke.return_value = Mock(content="80")mock_gatherer = Mock(return_value=[{"text": "evidence"}])checker = DualConfidenceChecker(mock_model, evidence_gatherer=mock_gatherer@@ -622,7 +622,7 @@ class TestCheckCandidate:)mock_model = Mock()- mock_model.generate.return_value = "80"+ mock_model.invoke.return_value = Mock(content="80")checker = DualConfidenceChecker(mock_model)candidate = MockCandidate(name="Test")@@ -645,7 +645,7 @@ class TestCheckCandidate:mock_model.invoke.return_value.content = ("POSITIVE: 0.7\nNEGATIVE: 0.1\nUNCERTAINTY: 0.2")- mock_model.generate.return_value = "80"+ mock_model.invoke.return_value = Mock(content="80")mock_gatherer = Mock(return_value=[{"text": "evidence"}])checker = DualConfidenceChecker(mock_model, evidence_gatherer=mock_gathererdiff --git a/tests/advanced_search_system/constraint_checking/test_dual_confidence_coverage.py b/tests/advanced_search_system/constraint_checking/test_dual_confidence_coverage.pyindex 2b1e7a0b97..a0ea0bc9ff 100644--- a/tests/advanced_search_system/constraint_checking/test_dual_confidence_coverage.py+++ b/tests/advanced_search_system/constraint_checking/test_dual_confidence_coverage.py@@ -10,7 +10,7 @@ Tests cover missing branches in:quality<50 rejects; parse failure accepts; exception accepts"""-from unittest.mock import MagicMock, patch+from unittest.mock import MagicMock, Mock, patchfrom local_deep_research.advanced_search_system.candidates.base_candidate import (Candidate,@@ -264,11 +264,11 @@ class TestLlmPrescreenCandidate:_candidate(), [], original_query=None)assert result["should_reject"] is False- checker.model.generate.assert_not_called()+ checker.model.invoke.assert_not_called()def test_quality_above_50_accepts(self):checker = _make_checker()- checker.model.generate.return_value = "75"+ checker.model.invoke.return_value = Mock(content="75")result = checker._llm_prescreen_candidate(_candidate(), [], original_query="What is the answer?")@@ -276,7 +276,7 @@ class TestLlmPrescreenCandidate:def test_quality_below_50_rejects(self):checker = _make_checker()- checker.model.generate.return_value = "20"+ checker.model.invoke.return_value = Mock(content="20")result = checker._llm_prescreen_candidate(_candidate(), [], original_query="What is the answer?")@@ -285,7 +285,7 @@ class TestLlmPrescreenCandidate:def test_parse_failure_accepts(self):checker = _make_checker()- checker.model.generate.return_value = "no number here"+ checker.model.invoke.return_value = Mock(content="no number here")result = checker._llm_prescreen_candidate(_candidate(), [], original_query="What is the answer?")@@ -293,7 +293,7 @@ class TestLlmPrescreenCandidate:def test_exception_accepts(self):checker = _make_checker()- checker.model.generate.side_effect = RuntimeError("network error")+ checker.model.invoke.side_effect = RuntimeError("network error")result = checker._llm_prescreen_candidate(_candidate(), [], original_query="What is X?")diff --git a/tests/news/core/test_storage.py b/tests/news/core/test_storage.pyindex 65dc6ef9f0..9d3783135d 100644--- a/tests/news/core/test_storage.py+++ b/tests/news/core/test_storage.py@@ -7,8 +7,6 @@ Tests cover:- SubscriptionStorage abstract interface- RatingStorage abstract interface- PreferenceStorage abstract interface-- SearchHistoryStorage abstract interface-- NewsItemStorage abstract interface- generate_id() utility method"""@@ -493,156 +491,6 @@ class TestPreferenceStorage:)-class TestSearchHistoryStorage:- """Tests for SearchHistoryStorage abstract interface."""-- def test_cannot_instantiate_directly(self):- """Test that SearchHistoryStorage cannot be instantiated directly."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- with pytest.raises(TypeError):- SearchHistoryStorage()-- def test_inherits_from_base_storage(self):- """Test that SearchHistoryStorage inherits from BaseStorage."""- from local_deep_research.news.core.storage import (- SearchHistoryStorage,- BaseStorage,- )-- assert issubclass(SearchHistoryStorage, BaseStorage)-- def test_defines_record_search_abstract_method(self):- """Test that record_search is an abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "record_search")- assert (- getattr(- SearchHistoryStorage.record_search,- "__isabstractmethod__",- False,- )- is True- )-- def test_defines_get_recent_searches_abstract_method(self):- """Test that get_recent_searches is an abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "get_recent_searches")- assert (- getattr(- SearchHistoryStorage.get_recent_searches,- "__isabstractmethod__",- False,- )- is True- )-- def test_defines_link_to_subscription_abstract_method(self):- """Test that link_to_subscription is an abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "link_to_subscription")- assert (- getattr(- SearchHistoryStorage.link_to_subscription,- "__isabstractmethod__",- False,- )- is True- )-- def test_defines_get_popular_searches_abstract_method(self):- """Test that get_popular_searches is an abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "get_popular_searches")- assert (- getattr(- SearchHistoryStorage.get_popular_searches,- "__isabstractmethod__",- False,- )- is True- )---class TestNewsItemStorage:- """Tests for NewsItemStorage abstract interface."""-- def test_cannot_instantiate_directly(self):- """Test that NewsItemStorage cannot be instantiated directly."""- from local_deep_research.news.core.storage import NewsItemStorage-- with pytest.raises(TypeError):- NewsItemStorage()-- def test_inherits_from_base_storage(self):- """Test that NewsItemStorage inherits from BaseStorage."""- from local_deep_research.news.core.storage import (- NewsItemStorage,- BaseStorage,- )-- assert issubclass(NewsItemStorage, BaseStorage)-- def test_defines_get_recent_abstract_method(self):- """Test that get_recent is an abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "get_recent")- assert (- getattr(NewsItemStorage.get_recent, "__isabstractmethod__", False)- is True- )-- def test_defines_store_batch_abstract_method(self):- """Test that store_batch is an abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "store_batch")- assert (- getattr(NewsItemStorage.store_batch, "__isabstractmethod__", False)- is True- )-- def test_defines_update_votes_abstract_method(self):- """Test that update_votes is an abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "update_votes")- assert (- getattr(NewsItemStorage.update_votes, "__isabstractmethod__", False)- is True- )-- def test_defines_get_by_category_abstract_method(self):- """Test that get_by_category is an abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "get_by_category")- assert (- getattr(- NewsItemStorage.get_by_category, "__isabstractmethod__", False- )- is True- )-- def test_defines_cleanup_old_items_abstract_method(self):- """Test that cleanup_old_items is an abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "cleanup_old_items")- assert (- getattr(- NewsItemStorage.cleanup_old_items, "__isabstractmethod__", False- )- is True- )--class TestConcreteImplementation:"""Tests for concrete implementation of BaseStorage."""@@ -713,8 +561,6 @@ class TestModuleImports:SubscriptionStorage,RatingStorage,PreferenceStorage,- SearchHistoryStorage,- NewsItemStorage,)assert BaseStorage is not None@@ -722,5 +568,3 @@ class TestModuleImports:assert SubscriptionStorage is not Noneassert RatingStorage is not Noneassert PreferenceStorage is not None- assert SearchHistoryStorage is not None- assert NewsItemStorage is not Nonediff --git a/tests/news/core/test_storage_deep_coverage.py b/tests/news/core/test_storage_deep_coverage.pyindex 2a862c87b4..56d9822b8d 100644--- a/tests/news/core/test_storage_deep_coverage.py+++ b/tests/news/core/test_storage_deep_coverage.py@@ -20,10 +20,8 @@ import pytestfrom local_deep_research.news.core.storage import (BaseStorage,CardStorage,- NewsItemStorage,PreferenceStorage,RatingStorage,- SearchHistoryStorage,SubscriptionStorage,)@@ -304,14 +302,6 @@ class TestAbstractInstantiation:with pytest.raises(TypeError):PreferenceStorage()- def test_search_history_storage_cannot_be_instantiated(self):- with pytest.raises(TypeError):- SearchHistoryStorage()-- def test_news_item_storage_cannot_be_instantiated(self):- with pytest.raises(TypeError):- NewsItemStorage()-# ---------------------------------------------------------------------------# Tests: BaseStorage.generate_iddiff --git a/tests/news/test_core_storage_extended.py b/tests/news/test_core_storage_extended.pyindex 5ffdbc239d..f33176464e 100644--- a/tests/news/test_core_storage_extended.py+++ b/tests/news/test_core_storage_extended.py@@ -7,8 +7,6 @@ Tests cover:- SubscriptionStorage interface- RatingStorage interface- PreferenceStorage interface-- SearchHistoryStorage interface-- NewsItemStorage interface- ID generation"""@@ -435,98 +433,6 @@ class TestPreferenceStorageInterface:assert hasattr(PreferenceStorage, "update_preference_embedding")-class TestSearchHistoryStorageInterface:- """Tests for SearchHistoryStorage interface."""-- def test_is_abstract_class(self):- """SearchHistoryStorage is an abstract class."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert issubclass(SearchHistoryStorage, ABC)-- def test_inherits_from_base_storage(self):- """SearchHistoryStorage inherits from BaseStorage."""- from local_deep_research.news.core.storage import (- SearchHistoryStorage,- BaseStorage,- )-- assert issubclass(SearchHistoryStorage, BaseStorage)-- def test_has_record_search_method(self):- """Has record_search abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "record_search")-- def test_has_get_recent_searches_method(self):- """Has get_recent_searches abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "get_recent_searches")-- def test_has_link_to_subscription_method(self):- """Has link_to_subscription abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "link_to_subscription")-- def test_has_get_popular_searches_method(self):- """Has get_popular_searches abstract method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert hasattr(SearchHistoryStorage, "get_popular_searches")---class TestNewsItemStorageInterface:- """Tests for NewsItemStorage interface."""-- def test_is_abstract_class(self):- """NewsItemStorage is an abstract class."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert issubclass(NewsItemStorage, ABC)-- def test_inherits_from_base_storage(self):- """NewsItemStorage inherits from BaseStorage."""- from local_deep_research.news.core.storage import (- NewsItemStorage,- BaseStorage,- )-- assert issubclass(NewsItemStorage, BaseStorage)-- def test_has_get_recent_method(self):- """Has get_recent abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "get_recent")-- def test_has_store_batch_method(self):- """Has store_batch abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "store_batch")-- def test_has_update_votes_method(self):- """Has update_votes abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "update_votes")-- def test_has_get_by_category_method(self):- """Has get_by_category abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "get_by_category")-- def test_has_cleanup_old_items_method(self):- """Has cleanup_old_items abstract method."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert hasattr(NewsItemStorage, "cleanup_old_items")--class TestStorageInheritanceChain:"""Tests for proper inheritance chain."""@@ -538,8 +444,6 @@ class TestStorageInheritanceChain:SubscriptionStorage,RatingStorage,PreferenceStorage,- SearchHistoryStorage,- NewsItemStorage,)storage_classes = [@@ -547,8 +451,6 @@ class TestStorageInheritanceChain:SubscriptionStorage,RatingStorage,PreferenceStorage,- SearchHistoryStorage,- NewsItemStorage,]for storage_class in storage_classes:@@ -561,8 +463,6 @@ class TestStorageInheritanceChain:SubscriptionStorage,RatingStorage,PreferenceStorage,- SearchHistoryStorage,- NewsItemStorage,)storage_classes = [@@ -570,8 +470,6 @@ class TestStorageInheritanceChain:SubscriptionStorage,RatingStorage,PreferenceStorage,- SearchHistoryStorage,- NewsItemStorage,]for storage_class in storage_classes:diff --git a/tests/news/test_core_storage_interfaces_comprehensive.py b/tests/news/test_core_storage_interfaces_comprehensive.pyindex 66aeae3b50..cee01d3424 100644--- a/tests/news/test_core_storage_interfaces_comprehensive.py+++ b/tests/news/test_core_storage_interfaces_comprehensive.py@@ -348,118 +348,6 @@ class TestPreferenceStorageInterface:assert "update_preference_embedding" in abstract_methods-class TestSearchHistoryStorageInterface:- """Tests for SearchHistoryStorage abstract interface."""-- def test_extends_base_storage(self):- """Test SearchHistoryStorage extends BaseStorage."""- from local_deep_research.news.core.storage import (- SearchHistoryStorage,- BaseStorage,- )-- assert issubclass(SearchHistoryStorage, BaseStorage)-- def test_cannot_instantiate_directly(self):- """Test cannot instantiate directly."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- with pytest.raises(TypeError):- SearchHistoryStorage()-- def test_requires_record_search_method(self):- """Test requires record_search method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- abstract_methods = SearchHistoryStorage.__abstractmethods__-- assert "record_search" in abstract_methods-- def test_requires_get_recent_searches_method(self):- """Test requires get_recent_searches method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- abstract_methods = SearchHistoryStorage.__abstractmethods__-- assert "get_recent_searches" in abstract_methods-- def test_requires_link_to_subscription_method(self):- """Test requires link_to_subscription method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- abstract_methods = SearchHistoryStorage.__abstractmethods__-- assert "link_to_subscription" in abstract_methods-- def test_requires_get_popular_searches_method(self):- """Test requires get_popular_searches method."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- abstract_methods = SearchHistoryStorage.__abstractmethods__-- assert "get_popular_searches" in abstract_methods---class TestNewsItemStorageInterface:- """Tests for NewsItemStorage abstract interface."""-- def test_extends_base_storage(self):- """Test NewsItemStorage extends BaseStorage."""- from local_deep_research.news.core.storage import (- NewsItemStorage,- BaseStorage,- )-- assert issubclass(NewsItemStorage, BaseStorage)-- def test_cannot_instantiate_directly(self):- """Test cannot instantiate directly."""- from local_deep_research.news.core.storage import NewsItemStorage-- with pytest.raises(TypeError):- NewsItemStorage()-- def test_requires_get_recent_method(self):- """Test requires get_recent method."""- from local_deep_research.news.core.storage import NewsItemStorage-- abstract_methods = NewsItemStorage.__abstractmethods__-- assert "get_recent" in abstract_methods-- def test_requires_store_batch_method(self):- """Test requires store_batch method."""- from local_deep_research.news.core.storage import NewsItemStorage-- abstract_methods = NewsItemStorage.__abstractmethods__-- assert "store_batch" in abstract_methods-- def test_requires_update_votes_method(self):- """Test requires update_votes method."""- from local_deep_research.news.core.storage import NewsItemStorage-- abstract_methods = NewsItemStorage.__abstractmethods__-- assert "update_votes" in abstract_methods-- def test_requires_get_by_category_method(self):- """Test requires get_by_category method."""- from local_deep_research.news.core.storage import NewsItemStorage-- abstract_methods = NewsItemStorage.__abstractmethods__-- assert "get_by_category" in abstract_methods-- def test_requires_cleanup_old_items_method(self):- """Test requires cleanup_old_items method."""- from local_deep_research.news.core.storage import NewsItemStorage-- abstract_methods = NewsItemStorage.__abstractmethods__-- assert "cleanup_old_items" in abstract_methods--class TestConcreteBaseStorageImplementation:"""Tests for a concrete BaseStorage implementation."""@@ -595,15 +483,3 @@ class TestStorageImports:from local_deep_research.news.core.storage import PreferenceStorageassert PreferenceStorage is not None-- def test_imports_search_history_storage(self):- """Test SearchHistoryStorage can be imported."""- from local_deep_research.news.core.storage import SearchHistoryStorage-- assert SearchHistoryStorage is not None-- def test_imports_news_item_storage(self):- """Test NewsItemStorage can be imported."""- from local_deep_research.news.core.storage import NewsItemStorage-- assert NewsItemStorage is not Nonediff --git a/tests/news/test_storage_coverage.py b/tests/news/test_storage_coverage.pyindex d1fe609006..a86bcc044b 100644--- a/tests/news/test_storage_coverage.py+++ b/tests/news/test_storage_coverage.py@@ -7,8 +7,6 @@ Tests cover:- SubscriptionStorage abstract interface- RatingStorage abstract interface- PreferenceStorage abstract interface-- SearchHistoryStorage abstract interface-- NewsItemStorage abstract interface- Concrete subclass instantiation and method dispatch- Edge cases: empty data, missing fields, duplicate IDs"""@@ -22,10 +20,8 @@ import pytestfrom local_deep_research.news.core.storage import (BaseStorage,CardStorage,- NewsItemStorage,PreferenceStorage,RatingStorage,- SearchHistoryStorage,SubscriptionStorage,)@@ -423,137 +419,6 @@ class ConcretePreferenceStorage(PreferenceStorage):return True-class ConcreteSearchHistoryStorage(SearchHistoryStorage):- """Minimal concrete implementation of SearchHistoryStorage."""-- def __init__(self):- self._store: Dict[str, Dict[str, Any]] = {}-- def create(self, data: Dict[str, Any]) -> str:- rid = self.generate_id()- self._store[rid] = data- return rid-- def get(self, id: str) -> Optional[Dict[str, Any]]:- return self._store.get(id)-- def update(self, id: str, data: Dict[str, Any]) -> bool:- if id not in self._store:- return False- self._store[id].update(data)- return True-- def delete(self, id: str) -> bool:- if id in self._store:- del self._store[id]- return True- return False-- def list(- self,- filters: Optional[Dict[str, Any]] = None,- limit: int = 100,- offset: int = 0,- ) -> List[Dict[str, Any]]:- return list(self._store.values())[offset : offset + limit]-- def record_search(- self, user_id: str, query: str, search_data: Dict[str, Any]- ) -> str:- return self.create({"user_id": user_id, "query": query, **search_data})-- def get_recent_searches(- self, user_id: str, hours: int = 48, limit: int = 50- ) -> List[Dict[str, Any]]:- return [v for v in self._store.values() if v.get("user_id") == user_id][- :limit- ]-- def link_to_subscription(- self, search_id: str, subscription_id: str- ) -> bool:- if search_id not in self._store:- return False- self._store[search_id]["subscription_id"] = subscription_id- return True-- def get_popular_searches(- self, hours: int = 24, limit: int = 20- ) -> List[Dict[str, Any]]:- return list(self._store.values())[:limit]---class ConcreteNewsItemStorage(NewsItemStorage):- """Minimal concrete implementation of NewsItemStorage."""-- def __init__(self):- self._store: Dict[str, Dict[str, Any]] = {}-- def create(self, data: Dict[str, Any]) -> str:- rid = self.generate_id()- self._store[rid] = {- **data,- "created_at": datetime.utcnow(),- "upvotes": 0,- "downvotes": 0,- }- return rid-- def get(self, id: str) -> Optional[Dict[str, Any]]:- return self._store.get(id)-- def update(self, id: str, data: Dict[str, Any]) -> bool:- if id not in self._store:- return False- self._store[id].update(data)- return True-- def delete(self, id: str) -> bool:- if id in self._store:- del self._store[id]- return True- return False-- def list(- self,- filters: Optional[Dict[str, Any]] = None,- limit: int = 100,- offset: int = 0,- ) -> List[Dict[str, Any]]:- return list(self._store.values())[offset : offset + limit]-- def get_recent(- self, hours: int = 24, limit: int = 50- ) -> List[Dict[str, Any]]:- return list(self._store.values())[:limit]-- def store_batch(self, news_items: List[Dict[str, Any]]) -> List[str]:- ids = []- for item in news_items:- ids.append(self.create(item))- return ids-- def update_votes(self, news_id: str, vote_type: str) -> bool:- if news_id not in self._store:- return False- if vote_type == "up":- self._store[news_id]["upvotes"] += 1- elif vote_type == "down":- self._store[news_id]["downvotes"] += 1- return True-- def get_by_category(- self, category: str, limit: int = 50- ) -> List[Dict[str, Any]]:- return [- v for v in self._store.values() if v.get("category") == category- ][:limit]-- def cleanup_old_items(self, days: int = 7) -> int:- # Simplified: just return 0 for tests- return 0--# ---------------------------------------------------------------------------# Test: cannot instantiate abstract classes directly# ---------------------------------------------------------------------------@@ -582,14 +447,6 @@ class TestAbstractInstantiation:with pytest.raises(TypeError):PreferenceStorage()- def test_search_history_storage_cannot_be_instantiated(self):- with pytest.raises(TypeError):- SearchHistoryStorage()-- def test_news_item_storage_cannot_be_instantiated(self):- with pytest.raises(TypeError):- NewsItemStorage()-class TestPartialAbstractImplementation:"""Verify that partial implementations still raise TypeError."""@@ -671,8 +528,6 @@ class TestGenerateId:ConcreteSubscriptionStorage,ConcreteRatingStorage,ConcretePreferenceStorage,- ConcreteSearchHistoryStorage,- ConcreteNewsItemStorage,]:instance = cls()gid = instance.generate_id()@@ -1063,153 +918,6 @@ class TestPreferenceStorage:assert storage.get_user_preferences("u1")["embedding"] == []-# ----------------------------------------------------------------------------# Test: SearchHistoryStorage-# ------------------------------------------------------------------------------class TestSearchHistoryStorage:- @pytest.fixture- def storage(self):- return ConcreteSearchHistoryStorage()-- def test_record_search(self, storage):- sid = storage.record_search("u1", "test query", {"source": "web"})- assert isinstance(sid, str)- record = storage.get(sid)- assert record["user_id"] == "u1"- assert record["query"] == "test query"-- def test_get_recent_searches(self, storage):- storage.record_search("u1", "q1", {})- storage.record_search("u1", "q2", {})- storage.record_search("u2", "q3", {})- result = storage.get_recent_searches("u1")- assert len(result) == 2-- def test_get_recent_searches_empty(self, storage):- assert storage.get_recent_searches("nobody") == []-- def test_get_recent_searches_limit(self, storage):- for i in range(10):- storage.record_search("u1", f"q{i}", {})- result = storage.get_recent_searches("u1", limit=3)- assert len(result) == 3-- def test_link_to_subscription(self, storage):- sid = storage.record_search("u1", "q", {})- assert storage.link_to_subscription(sid, "sub-123") is True- record = storage.get(sid)- assert record["subscription_id"] == "sub-123"-- def test_link_to_subscription_nonexistent(self, storage):- assert storage.link_to_subscription("bad-id", "sub-1") is False-- def test_get_popular_searches(self, storage):- storage.record_search("u1", "trending topic", {})- storage.record_search("u2", "other topic", {})- popular = storage.get_popular_searches()- assert len(popular) == 2-- def test_get_popular_searches_limit(self, storage):- for i in range(30):- storage.record_search("u1", f"q{i}", {})- popular = storage.get_popular_searches(limit=5)- assert len(popular) == 5-- def test_get_popular_searches_empty(self, storage):- assert storage.get_popular_searches() == []---# ----------------------------------------------------------------------------# Test: NewsItemStorage-# ------------------------------------------------------------------------------class TestNewsItemStorage:- @pytest.fixture- def storage(self):- return ConcreteNewsItemStorage()-- def test_create_news_item(self, storage):- nid = storage.create({"title": "Breaking News", "category": "tech"})- item = storage.get(nid)- assert item["title"] == "Breaking News"- assert item["upvotes"] == 0- assert item["downvotes"] == 0-- def test_get_recent_empty(self, storage):- assert storage.get_recent() == []-- def test_get_recent_with_items(self, storage):- storage.create({"title": "N1"})- storage.create({"title": "N2"})- assert len(storage.get_recent()) == 2-- def test_get_recent_limit(self, storage):- for i in range(10):- storage.create({"title": f"N{i}"})- assert len(storage.get_recent(limit=3)) == 3-- def test_store_batch(self, storage):- items = [{"title": f"Batch {i}"} for i in range(5)]- ids = storage.store_batch(items)- assert len(ids) == 5- for nid in ids:- assert storage.get(nid) is not None-- def test_store_batch_empty(self, storage):- ids = storage.store_batch([])- assert ids == []-- def test_update_votes_up(self, storage):- nid = storage.create({"title": "N"})- assert storage.update_votes(nid, "up") is True- assert storage.get(nid)["upvotes"] == 1-- def test_update_votes_down(self, storage):- nid = storage.create({"title": "N"})- assert storage.update_votes(nid, "down") is True- assert storage.get(nid)["downvotes"] == 1-- def test_update_votes_multiple(self, storage):- nid = storage.create({"title": "N"})- storage.update_votes(nid, "up")- storage.update_votes(nid, "up")- storage.update_votes(nid, "down")- item = storage.get(nid)- assert item["upvotes"] == 2- assert item["downvotes"] == 1-- def test_update_votes_nonexistent(self, storage):- assert storage.update_votes("bad-id", "up") is False-- def test_get_by_category(self, storage):- storage.create({"title": "T1", "category": "tech"})- storage.create({"title": "T2", "category": "science"})- storage.create({"title": "T3", "category": "tech"})- result = storage.get_by_category("tech")- assert len(result) == 2-- def test_get_by_category_empty(self, storage):- assert storage.get_by_category("nonexistent") == []-- def test_get_by_category_limit(self, storage):- for i in range(10):- storage.create({"title": f"T{i}", "category": "tech"})- result = storage.get_by_category("tech", limit=3)- assert len(result) == 3-- def test_cleanup_old_items(self, storage):- storage.create({"title": "old"})- count = storage.cleanup_old_items(days=7)- assert isinstance(count, int)-- def test_cleanup_old_items_custom_days(self, storage):- count = storage.cleanup_old_items(days=1)- assert count == 0--# ---------------------------------------------------------------------------# Test: Inheritance hierarchy# ---------------------------------------------------------------------------@@ -1228,12 +936,6 @@ class TestInheritanceHierarchy:def test_preference_storage_is_base_storage(self):assert issubclass(PreferenceStorage, BaseStorage)- def test_search_history_storage_is_base_storage(self):- assert issubclass(SearchHistoryStorage, BaseStorage)-- def test_news_item_storage_is_base_storage(self):- assert issubclass(NewsItemStorage, BaseStorage)-def test_concrete_card_isinstance(self):s = ConcreteCardStorage()assert isinstance(s, BaseStorage)@@ -1324,37 +1026,6 @@ class TestAbstractMethodSignatures:actual = set(PreferenceStorage.__abstractmethods__)assert expected == actual- def test_search_history_storage_abstract_methods(self):- expected = {- "create",- "get",- "update",- "delete",- "list",- "record_search",- "get_recent_searches",- "link_to_subscription",- "get_popular_searches",- }- actual = set(SearchHistoryStorage.__abstractmethods__)- assert expected == actual-- def test_news_item_storage_abstract_methods(self):- expected = {- "create",- "get",- "update",- "delete",- "list",- "get_recent",- "store_batch",- "update_votes",- "get_by_category",- "cleanup_old_items",- }- actual = set(NewsItemStorage.__abstractmethods__)- assert expected == actual-# ---------------------------------------------------------------------------# Test: Default parametersdiff --git a/tests/news/test_storage_interfaces_deep_behavior.py b/tests/news/test_storage_interfaces_deep_behavior.pyindex 1f98c89faf..0a5ebb7ff3 100644--- a/tests/news/test_storage_interfaces_deep_behavior.py+++ b/tests/news/test_storage_interfaces_deep_behavior.py@@ -1,7 +1,7 @@"""Deep behavioral tests for storage interfaces and base storage patterns.Tests BaseStorage, CardStorage, SubscriptionStorage, RatingStorage,-PreferenceStorage, SearchHistoryStorage, and NewsItemStorage interfaces.+and PreferenceStorage interfaces."""import uuid@@ -14,8 +14,6 @@ from local_deep_research.news.core.storage import (RatingStorage,SubscriptionStorage,PreferenceStorage,- SearchHistoryStorage,- NewsItemStorage,)@@ -248,37 +246,6 @@ class TestPreferenceStorageAbstract:assert "update_preference_embedding" in abstract_methods-class TestSearchHistoryStorageAbstract:- """Tests that SearchHistoryStorage enforces abstract methods."""-- def test_cannot_instantiate(self):- with pytest.raises(TypeError):- SearchHistoryStorage()-- def test_required_methods(self):- abstract_methods = SearchHistoryStorage.__abstractmethods__- assert "record_search" in abstract_methods- assert "get_recent_searches" in abstract_methods- assert "link_to_subscription" in abstract_methods- assert "get_popular_searches" in abstract_methods---class TestNewsItemStorageAbstract:- """Tests that NewsItemStorage enforces abstract methods."""-- def test_cannot_instantiate(self):- with pytest.raises(TypeError):- NewsItemStorage()-- def test_required_methods(self):- abstract_methods = NewsItemStorage.__abstractmethods__- assert "get_recent" in abstract_methods- assert "store_batch" in abstract_methods- assert "update_votes" in abstract_methods- assert "get_by_category" in abstract_methods- assert "cleanup_old_items" in abstract_methods--# --- Interface inheritance chain ---@@ -297,12 +264,6 @@ class TestStorageInheritance:def test_preference_storage_extends_base(self):assert issubclass(PreferenceStorage, BaseStorage)- def test_search_history_extends_base(self):- assert issubclass(SearchHistoryStorage, BaseStorage)-- def test_news_item_extends_base(self):- assert issubclass(NewsItemStorage, BaseStorage)-def test_all_share_generate_id(self):"""All storage interfaces should inherit generate_id from BaseStorage."""assert hasattr(CardStorage, "generate_id")@@ -380,24 +341,6 @@ class TestStorageDefaultParameters:sig = inspect.signature(RatingStorage.get_user_ratings)assert sig.parameters["limit"].default == 100- def test_get_recent_searches_default_hours(self):- import inspect-- sig = inspect.signature(SearchHistoryStorage.get_recent_searches)- assert sig.parameters["hours"].default == 48-- def test_get_recent_searches_default_limit(self):- import inspect-- sig = inspect.signature(SearchHistoryStorage.get_recent_searches)- assert sig.parameters["limit"].default == 50-- def test_cleanup_old_items_default_days(self):- import inspect-- sig = inspect.signature(NewsItemStorage.cleanup_old_items)- assert sig.parameters["days"].default == 7-def test_get_due_subscriptions_default_limit(self):import inspectdiff --git a/tests/research_library/services/test_download_service_coverage.py b/tests/research_library/services/test_download_service_coverage.pyindex c66e6f4402..19fc029783 100644--- a/tests/research_library/services/test_download_service_coverage.py+++ b/tests/research_library/services/test_download_service_coverage.py@@ -728,21 +728,6 @@ class TestDownloadBiorxiv:assert svc._download_biorxiv("https://biorxiv.org/123") is None-# ============================================================-# _download_medrxiv-# ============================================================---class TestDownloadMedrxiv:- def test_delegates_to_biorxiv(self, svc):- with patch.object(- svc, "_download_biorxiv", return_value=b"pdf"- ) as mock_dl:- result = svc._download_medrxiv("https://medrxiv.org/123")- mock_dl.assert_called_once_with("https://medrxiv.org/123")- assert result == b"pdf"--# ============================================================# _try_europe_pmc# ============================================================diff --git a/tests/research_library/services/test_library_rag_service.py b/tests/research_library/services/test_library_rag_service.pyindex 02b1e047f6..5b525beab4 100644--- a/tests/research_library/services/test_library_rag_service.py+++ b/tests/research_library/services/test_library_rag_service.py@@ -2,7 +2,6 @@Tests for LibraryRAGService."""-import pytestfrom unittest.mock import Mock, MagicMockfrom pathlib import Pathfrom langchain_core.documents import Document as LangchainDocument@@ -579,51 +578,6 @@ class TestLibraryRAGServiceRemoveDocument:assert "not found" in result["error"].lower()-class TestLibraryRAGServiceSearchLibrary:- """Tests for library search."""-- def test_search_library_not_implemented(self, mocker):- """Raises NotImplementedError for search."""- mock_session = MagicMock()- mock_session.__enter__ = Mock(return_value=mock_session)- mock_session.__exit__ = Mock(return_value=False)-- mocker.patch(- "local_deep_research.research_library.services.library_rag_service.get_user_db_session",- return_value=mock_session,- )-- # Mock embedding manager- mock_embedding_manager = Mock()- mock_embedding_manager.embeddings = Mock()-- # Mock text splitter- mock_splitter = Mock()- mocker.patch(- "local_deep_research.research_library.services.library_rag_service.get_text_splitter",- return_value=mock_splitter,- )-- # Mock integrity manager- mock_integrity = Mock()- mocker.patch(- "local_deep_research.research_library.services.library_rag_service.FileIntegrityManager",- return_value=mock_integrity,- )-- from local_deep_research.research_library.services.library_rag_service import (- LibraryRAGService,- )-- service = LibraryRAGService(- username="test_user",- embedding_manager=mock_embedding_manager,- )-- with pytest.raises(NotImplementedError):- service.search_library("test query")--class TestLibraryRAGServiceLoadOrCreateFaissIndex:"""Tests for FAISS index loading/creation."""diff --git a/tests/research_library/services/test_library_rag_service_coverage.py b/tests/research_library/services/test_library_rag_service_coverage.pyindex dc3c292ee7..58906406cd 100644--- a/tests/research_library/services/test_library_rag_service_coverage.py+++ b/tests/research_library/services/test_library_rag_service_coverage.py@@ -10,14 +10,12 @@ Focuses on logic paths not exercised by the existing test_library_rag_service.pyload failure, corrupted unlink failure- index_document chunk indexing, empty text, skip already indexed- index_all_documents with progress callback, stores settings-- search_library raises NotImplementedError"""import hashlibfrom pathlib import Pathfrom unittest.mock import MagicMock, patch-import pytestfrom langchain_core.documents import Document as LangchainDocument# ---------------------------------------------------------------------------@@ -720,23 +718,6 @@ class TestIndexAllDocuments:assert len(result["errors"]) == 1-# =========================================================================-# search_library-# =========================================================================-class TestSearchLibrary:- """Tests for search_library."""-- def test_raises_not_implemented(self):- svc = _make_service()- with pytest.raises(NotImplementedError):- svc.search_library("some query")-- def test_accepts_limit_and_threshold(self):- svc = _make_service()- with pytest.raises(NotImplementedError):- svc.search_library("query", limit=5, score_threshold=0.5)--# =========================================================================# db_password property# =========================================================================diff --git a/tests/research_library/utils/test_utils.py b/tests/research_library/utils/test_utils.pyindex 02a8794f2a..023527fcd0 100644--- a/tests/research_library/utils/test_utils.py+++ b/tests/research_library/utils/test_utils.py@@ -1,7 +1,6 @@"""Tests for research_library/utils/__init__.py — utility functions."""import hashlib-from pathlib import Pathfrom unittest.mock import MagicMock, patch@@ -192,43 +191,12 @@ class TestOpenFileLocation:# ----------------------------------------------------------------------------# get_relative_library_path / get_absolute_library_path+# get_absolute_library_path# ---------------------------------------------------------------------------class TestLibraryPathConversions:- """Tests for get_relative_library_path and get_absolute_library_path."""-- @patch(- "local_deep_research.research_library.utils.get_library_storage_path"- )- def test_relative_path_within_library(self, mock_storage, tmp_path):- library_root = tmp_path / "library" / "alice"- library_root.mkdir(parents=True)- mock_storage.return_value = library_root-- from local_deep_research.research_library.utils import (- get_relative_library_path,- )-- abs_path = str(library_root / "subdir" / "file.pdf")- result = get_relative_library_path(abs_path, "alice")- assert result == str(Path("subdir") / "file.pdf")-- @patch(- "local_deep_research.research_library.utils.get_library_storage_path"- )- def test_relative_path_outside_library_returns_filename(- self, mock_storage, tmp_path- ):- mock_storage.return_value = tmp_path / "library"-- from local_deep_research.research_library.utils import (- get_relative_library_path,- )-- result = get_relative_library_path("/other/dir/file.pdf", "alice")- assert result == "file.pdf"+ """Tests for get_absolute_library_path."""@patch("local_deep_research.research_library.utils.get_library_storage_path"