Skip to content

~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.

fix: Update tests to use settings_snapshot instead of deprecated functions

LearningCircuitcc057e541305
diff --git a/tests/test_api_key_configuration.py b/tests/test_api_key_configuration.py
index 088df7a81c..01058221b5 100644
--- a/tests/test_api_key_configuration.py
+++ b/tests/test_api_key_configuration.py
@@ -290,29 +290,65 @@ class TestAPIKeyConfiguration:
def test_api_availability_checks(self):
"""Test the availability check functions for different providers."""
- with patch(
- "local_deep_research.config.llm_config.get_setting_from_db_main_thread"
- ) as mock_get_db_setting:
- # Test OpenAI availability
- mock_get_db_setting.return_value = "test-openai-key"
- assert is_openai_available() is True
+ # Test OpenAI availability with settings snapshot
+ settings_with_openai = {
+ "llm.openai.api_key": {"value": "test-openai-key", "type": "str"}
+ }
+ assert (
+ is_openai_available(settings_snapshot=settings_with_openai) is True
+ )
- mock_get_db_setting.return_value = None
- assert is_openai_available() is False
+ settings_without_openai = {
+ "llm.openai.api_key": {"value": None, "type": "str"}
+ }
+ assert (
+ is_openai_available(settings_snapshot=settings_without_openai)
+ is False
+ )
- # Test Anthropic availability
- mock_get_db_setting.return_value = "test-anthropic-key"
- assert is_anthropic_available() is True
+ # Test Anthropic availability
+ settings_with_anthropic = {
+ "llm.anthropic.api_key": {
+ "value": "test-anthropic-key",
+ "type": "str",
+ }
+ }
+ assert (
+ is_anthropic_available(settings_snapshot=settings_with_anthropic)
+ is True
+ )
- mock_get_db_setting.return_value = None
- assert is_anthropic_available() is False
+ settings_without_anthropic = {
+ "llm.anthropic.api_key": {"value": None, "type": "str"}
+ }
+ assert (
+ is_anthropic_available(settings_snapshot=settings_without_anthropic)
+ is False
+ )
- # Test OpenAI endpoint availability
- mock_get_db_setting.return_value = "test-endpoint-key"
- assert is_openai_endpoint_available() is True
+ # Test OpenAI endpoint availability
+ settings_with_endpoint = {
+ "llm.openai_endpoint.api_key": {
+ "value": "test-endpoint-key",
+ "type": "str",
+ }
+ }
+ assert (
+ is_openai_endpoint_available(
+ settings_snapshot=settings_with_endpoint
+ )
+ is True
+ )
- mock_get_db_setting.return_value = None
- assert is_openai_endpoint_available() is False
+ settings_without_endpoint = {
+ "llm.openai_endpoint.api_key": {"value": None, "type": "str"}
+ }
+ assert (
+ is_openai_endpoint_available(
+ settings_snapshot=settings_without_endpoint
+ )
+ is False
+ )
class TestLLMIntegration:
diff --git a/tests/test_citation_handler.py b/tests/test_citation_handler.py
index a39d7189a4..0badb39f23 100644
--- a/tests/test_citation_handler.py
+++ b/tests/test_citation_handler.py
@@ -136,16 +136,13 @@ def test_analyze_initial(citation_handler, sample_search_results):
def test_analyze_followup(citation_handler, sample_search_results, monkeypatch):
"""Test follow-up analysis with previous knowledge."""
- # The mock db_utils module is already set up in conftest.py
- # But we can further override it for this specific test if needed
- def mock_get_db_setting(key, default=None):
- if key == "general.enable_fact_checking":
- return True
- return default
-
- monkeypatch.setattr(
- "src.local_deep_research.citation_handler.get_setting_from_db_main_thread",
- mock_get_db_setting,
+ # Set fact checking enabled through settings snapshot
+ citation_handler.settings_snapshot = {
+ "general.enable_fact_checking": {"value": True, "type": "bool"}
+ }
+ # Update the handler's settings as well
+ citation_handler._handler.settings_snapshot = (
+ citation_handler.settings_snapshot
)
result = citation_handler.analyze_followup(
@@ -177,20 +174,13 @@ def test_analyze_followup_no_fact_check(
):
"""Test follow-up analysis with fact checking disabled."""
- # Override the get_db_setting function for this test
- def mock_get_db_setting(key, default=None):
- if key == "general.enable_fact_checking":
- return False
- return default
-
- # Patch in both locations where it might be imported
- monkeypatch.setattr(
- "src.local_deep_research.citation_handler.get_setting_from_db_main_thread",
- mock_get_db_setting,
- )
- monkeypatch.setattr(
- "src.local_deep_research.citation_handlers.standard_citation_handler.get_setting_from_db_main_thread",
- mock_get_db_setting,
+ # Set fact checking disabled through settings snapshot
+ citation_handler.settings_snapshot = {
+ "general.enable_fact_checking": {"value": False, "type": "bool"}
+ }
+ # Update the handler's settings as well
+ citation_handler._handler.settings_snapshot = (
+ citation_handler.settings_snapshot
)
citation_handler.analyze_followup(