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: align tests with strategy refactor and fix mock/assertion mismatches (#3319)

LearningCircuitcbab72f7184c
diff --git a/src/local_deep_research/config/llm_config.py b/src/local_deep_research/config/llm_config.py
index 0ed93b91c7..425b40bfa1 100644
--- a/src/local_deep_research/config/llm_config.py
+++ b/src/local_deep_research/config/llm_config.py
@@ -320,7 +320,7 @@ def get_llm(
# Validate the result is a BaseChatModel
if not isinstance(llm_instance, BaseChatModel):
- raise TypeError(
+ raise ValueError(
f"Factory function for {provider} must return a BaseChatModel instance, "
f"got {type(llm_instance).__name__}"
)
@@ -328,7 +328,7 @@ def get_llm(
# It's already a proper LLM instance, use it directly
llm_instance = custom_llm
else:
- raise TypeError(
+ raise ValueError(
f"Registered LLM {provider} must be either a BaseChatModel instance "
f"or a callable factory function. Got: {type(custom_llm).__name__}"
)
diff --git a/tests/library/download_management/test_status_tracker_extended.py b/tests/library/download_management/test_status_tracker_extended.py
index f0b9c2326d..25884705cf 100644
--- a/tests/library/download_management/test_status_tracker_extended.py
+++ b/tests/library/download_management/test_status_tracker_extended.py
@@ -110,6 +110,8 @@ class TestStatusTracking:
mock_status.status = "available"
mock_status.retry_after_timestamp = None
mock_status.today_retry_count = 3
+ mock_status.total_retry_count = 3
+ mock_status.last_attempt_at = datetime.now(UTC)
mock_session = MagicMock()
mock_session.__enter__ = MagicMock(return_value=mock_session)
@@ -138,6 +140,8 @@ class TestStatusTracking:
hours=1
) # Cooldown expired
mock_status.today_retry_count = 4 # Exceeded limit
+ mock_status.total_retry_count = 4
+ mock_status.last_attempt_at = datetime.now(UTC)
mock_session = MagicMock()
mock_session.__enter__ = MagicMock(return_value=mock_session)
@@ -310,6 +314,8 @@ class TestStatusTracking:
mock_status.status = "temporarily_failed"
mock_status.retry_after_timestamp = naive_time
mock_status.today_retry_count = 0
+ mock_status.total_retry_count = 0
+ mock_status.last_attempt_at = datetime.now()
mock_session = MagicMock()
mock_session.__enter__ = MagicMock(return_value=mock_session)
@@ -365,6 +371,8 @@ class TestStatusTracking:
mock_status.status = "available"
mock_status.retry_after_timestamp = None
mock_status.today_retry_count = 3 # At limit
+ mock_status.total_retry_count = 3
+ mock_status.last_attempt_at = datetime.now(UTC)
mock_session = MagicMock()
mock_session.__enter__ = MagicMock(return_value=mock_session)
@@ -658,6 +666,8 @@ class TestCleanupOperations:
mock_status.status = "temporarily_failed"
mock_status.retry_after_timestamp = expired_time
mock_status.today_retry_count = 0
+ mock_status.total_retry_count = 0
+ mock_status.last_attempt_at = datetime.now(UTC) - timedelta(hours=2)
mock_session = MagicMock()
mock_session.__enter__ = MagicMock(return_value=mock_session)
diff --git a/tests/mcp/test_additional_coverage.py b/tests/mcp/test_additional_coverage.py
index cce96cc03f..508072cb5a 100644
--- a/tests/mcp/test_additional_coverage.py
+++ b/tests/mcp/test_additional_coverage.py
@@ -389,11 +389,12 @@ class TestAvailableStrategiesContent:
# These are the actual strategies defined in the system
expected_strategies = [
"source-based",
- "rapid",
- "iterative",
- "evidence",
"focused-iteration",
+ "focused-iteration-standard",
+ "iterative-refinement",
+ "topic-organization",
"mcp",
+ "langgraph-agent",
]
for expected in expected_strategies:
diff --git a/tests/mcp/test_integration.py b/tests/mcp/test_integration.py
index 9ead13cdd2..54a7958785 100644
--- a/tests/mcp/test_integration.py
+++ b/tests/mcp/test_integration.py
@@ -76,7 +76,7 @@ class TestSettingsFlow:
quick_research(
query="test",
search_engine="wikipedia",
- strategy="rapid",
+ strategy="source-based",
iterations=3,
)
@@ -85,7 +85,7 @@ class TestSettingsFlow:
assert "overrides" in call_kwargs
overrides = call_kwargs["overrides"]
assert overrides["search.tool"] == "wikipedia"
- assert overrides["search.search_strategy"] == "rapid"
+ assert overrides["search.search_strategy"] == "source-based"
assert overrides["search.iterations"] == 3
def test_settings_snapshot_passed_to_api(self):
@@ -251,9 +251,9 @@ class TestDiscoveryToolsIntegration:
# Check for key strategies
assert "source-based" in strategy_names
- assert "rapid" in strategy_names
- assert "iterative" in strategy_names
- assert "evidence" in strategy_names
+ assert "focused-iteration" in strategy_names
+ assert "iterative-refinement" in strategy_names
+ assert "topic-organization" in strategy_names
def test_get_configuration_structure(self):
"""Verify get_configuration returns expected structure."""
diff --git a/tests/mcp/test_mcp_protocol.py b/tests/mcp/test_mcp_protocol.py
index 788abc4b8c..4884ac113f 100644
--- a/tests/mcp/test_mcp_protocol.py
+++ b/tests/mcp/test_mcp_protocol.py
@@ -211,7 +211,7 @@ class TestAvailableStrategies:
)
strategies = get_available_strategies()
- assert len(strategies) >= 10 # We defined 17 strategies
+ assert len(strategies) >= 7 # We defined 7 strategies
def test_available_strategies_have_required_fields(self):
"""Verify each strategy has name and description."""
@@ -240,15 +240,15 @@ class TestAvailableStrategies:
strategy_names = [s["name"] for s in strategies]
assert "source-based" in strategy_names
- def test_rapid_strategy_exists(self):
- """Verify rapid strategy is in the list."""
+ def test_focused_iteration_strategy_exists(self):
+ """Verify focused-iteration strategy is in the list."""
from local_deep_research.search_system_factory import (
get_available_strategies,
)
strategies = get_available_strategies()
strategy_names = [s["name"] for s in strategies]
- assert "rapid" in strategy_names
+ assert "focused-iteration" in strategy_names
class TestHelperFunctions:
diff --git a/tests/mcp/test_server.py b/tests/mcp/test_server.py
index b543f15a98..79432be4cf 100644
--- a/tests/mcp/test_server.py
+++ b/tests/mcp/test_server.py
@@ -49,7 +49,7 @@ class TestQuickResearch:
result = quick_research(
query="Test query",
search_engine="wikipedia",
- strategy="rapid",
+ strategy="source-based",
iterations=2,
)
@@ -594,14 +594,14 @@ class TestSettingsOverrides:
result = _build_settings_overrides(
search_engine="wikipedia",
- strategy="rapid",
+ strategy="source-based",
iterations=3,
questions_per_iteration=5,
temperature=0.5,
)
assert result["search.tool"] == "wikipedia"
- assert result["search.search_strategy"] == "rapid"
+ assert result["search.search_strategy"] == "source-based"
assert result["search.iterations"] == 3
assert result["search.questions_per_iteration"] == 5
assert result["llm.temperature"] == 0.5
diff --git a/tests/news/test_web_blueprint.py b/tests/news/test_web_blueprint.py
index 7ea7fc1263..1f74d20043 100644
--- a/tests/news/test_web_blueprint.py
+++ b/tests/news/test_web_blueprint.py
@@ -104,7 +104,7 @@ class TestNewsPageRoute:
assert args[0] == "pages/news.html"
def test_news_page_passes_strategies_list(self, client):
- """Test that 4 strategies are passed to template."""
+ """Test that strategies are passed to template."""
with patch(
"local_deep_research.news.web.render_template"
) as mock_render:
@@ -114,14 +114,15 @@ class TestNewsPageRoute:
args, kwargs = mock_render.call_args
assert "strategies" in kwargs
- assert len(kwargs["strategies"]) == 4
- assert "topic_based" in kwargs["strategies"]
- assert "news_aggregation" in kwargs["strategies"]
- assert "source_based" in kwargs["strategies"]
- assert "focused_iteration" in kwargs["strategies"]
+ assert len(kwargs["strategies"]) == 7
+ strategy_names = [s["name"] for s in kwargs["strategies"]]
+ assert "source-based" in strategy_names
+ assert "focused-iteration" in strategy_names
+ assert "topic-organization" in strategy_names
+ assert "iterative-refinement" in strategy_names
- def test_news_page_passes_default_strategy(self, client):
- """Test that default_strategy is 'topic_based'."""
+ def test_news_page_passes_strategies_with_source_based(self, client):
+ """Test that source-based strategy is present in strategies."""
with patch(
"local_deep_research.news.web.render_template"
) as mock_render:
@@ -130,7 +131,8 @@ class TestNewsPageRoute:
client.get("/news/")
args, kwargs = mock_render.call_args
- assert kwargs["default_strategy"] == "topic_based"
+ strategy_names = [s["name"] for s in kwargs["strategies"]]
+ assert "source-based" in strategy_names
class TestSubscriptionsPageRoute:
diff --git a/tests/news/test_web_routes_comprehensive.py b/tests/news/test_web_routes_comprehensive.py
index aaaf22a60f..658b151a3a 100644
--- a/tests/news/test_web_routes_comprehensive.py
+++ b/tests/news/test_web_routes_comprehensive.py
@@ -88,8 +88,9 @@ class TestNewsPageRoute:
client.get("/news/")
call_kwargs = mock_render.call_args[1]
strategies = call_kwargs["strategies"]
- assert "topic_based" in strategies
- assert "news_aggregation" in strategies
+ strategy_names = [s["name"] for s in strategies]
+ assert "topic-organization" in strategy_names
+ assert "source-based" in strategy_names
class TestSubscriptionsPageRoute:
@@ -396,8 +397,8 @@ class TestDefaultSettings:
class TestStrategyList:
"""Tests for strategy list in news page."""
- def test_strategies_include_topic_based(self):
- """Test strategies list includes topic_based."""
+ def test_strategies_include_topic_organization(self):
+ """Test strategies list includes topic-organization."""
from local_deep_research.news.web import create_news_blueprint
from flask import Flask
@@ -413,10 +414,11 @@ class TestStrategyList:
with app.test_client() as client:
client.get("/news/")
call_kwargs = mock_render.call_args[1]
- assert "topic_based" in call_kwargs["strategies"]
+ strategy_names = [s["name"] for s in call_kwargs["strategies"]]
+ assert "topic-organization" in strategy_names
- def test_strategies_include_news_aggregation(self):
- """Test strategies list includes news_aggregation."""
+ def test_strategies_include_iterative_refinement(self):
+ """Test strategies list includes iterative-refinement."""
from local_deep_research.news.web import create_news_blueprint
from flask import Flask
@@ -432,10 +434,11 @@ class TestStrategyList:
with app.test_client() as client:
client.get("/news/")
call_kwargs = mock_render.call_args[1]
- assert "news_aggregation" in call_kwargs["strategies"]
+ strategy_names = [s["name"] for s in call_kwargs["strategies"]]
+ assert "iterative-refinement" in strategy_names
def test_strategies_include_source_based(self):
- """Test strategies list includes source_based."""
+ """Test strategies list includes source-based."""
from local_deep_research.news.web import create_news_blueprint
from flask import Flask
@@ -451,10 +454,11 @@ class TestStrategyList:
with app.test_client() as client:
client.get("/news/")
call_kwargs = mock_render.call_args[1]
- assert "source_based" in call_kwargs["strategies"]
+ strategy_names = [s["name"] for s in call_kwargs["strategies"]]
+ assert "source-based" in strategy_names
def test_strategies_include_focused_iteration(self):
- """Test strategies list includes focused_iteration."""
+ """Test strategies list includes focused-iteration."""
from local_deep_research.news.web import create_news_blueprint
from flask import Flask
@@ -470,10 +474,11 @@ class TestStrategyList:
with app.test_client() as client:
client.get("/news/")
call_kwargs = mock_render.call_args[1]
- assert "focused_iteration" in call_kwargs["strategies"]
+ strategy_names = [s["name"] for s in call_kwargs["strategies"]]
+ assert "focused-iteration" in strategy_names
- def test_default_strategy_is_topic_based(self):
- """Test default strategy is topic_based."""
+ def test_strategies_include_mcp(self):
+ """Test strategies list includes mcp."""
from local_deep_research.news.web import create_news_blueprint
from flask import Flask
@@ -489,4 +494,5 @@ class TestStrategyList:
with app.test_client() as client:
client.get("/news/")
call_kwargs = mock_render.call_args[1]
- assert call_kwargs["default_strategy"] == "topic_based"
+ strategy_names = [s["name"] for s in call_kwargs["strategies"]]
+ assert "mcp" in strategy_names
diff --git a/tests/research_library/services/test_library_service_collections_stats.py b/tests/research_library/services/test_library_service_collections_stats.py
index 0e65359197..3576de559e 100644
--- a/tests/research_library/services/test_library_service_collections_stats.py
+++ b/tests/research_library/services/test_library_service_collections_stats.py
@@ -257,7 +257,7 @@ class TestGetResearchListWithStats:
mock_domain_query.filter.return_value = mock_domain_query
mock_domain_query.group_by.return_value = mock_domain_query
mock_domain_query.limit.return_value = mock_domain_query
- mock_domain_query.all.return_value = [("arxiv.org", 3)]
+ mock_domain_query.all.return_value = [(1, "arxiv.org", 3)]
call_count = {"n": 0}
@@ -407,8 +407,8 @@ class TestGetResearchListWithStats:
mock_domain_query.group_by.return_value = mock_domain_query
mock_domain_query.limit.return_value = mock_domain_query
mock_domain_query.all.return_value = [
- ("arxiv.org", 3),
- ("pubmed", 2),
+ (1, "arxiv.org", 3),
+ (1, "pubmed", 2),
]
call_count = {"n": 0}
diff --git a/tests/security/test_auth_security.py b/tests/security/test_auth_security.py
index b49ecd2d70..82a35dd1b4 100644
--- a/tests/security/test_auth_security.py
+++ b/tests/security/test_auth_security.py
@@ -86,6 +86,7 @@ class TestSessionSecurity:
app, _ = create_app() # Unpack tuple (app, socket_service)
app.config["TESTING"] = True
app.config["SECRET_KEY"] = "test-secret-key"
+ app.config["WTF_CSRF_ENABLED"] = False
return app.test_client()
def test_session_cookie_secure_flags(self, client):
diff --git a/tests/web/routes/test_metrics_routes.py b/tests/web/routes/test_metrics_routes.py
index a945f5e525..2f995cb67a 100644
--- a/tests/web/routes/test_metrics_routes.py
+++ b/tests/web/routes/test_metrics_routes.py
@@ -689,6 +689,6 @@ class TestGetAvailableStrategies:
strategies = get_available_strategies()
strategy_names = [s["name"] for s in strategies]
- assert "standard" in strategy_names
- assert "rapid" in strategy_names
- assert "smart" in strategy_names
+ assert "source-based" in strategy_names
+ assert "focused-iteration" in strategy_names
+ assert "iterative-refinement" in strategy_names
diff --git a/tests/web/routes/test_metrics_routes_coverage.py b/tests/web/routes/test_metrics_routes_coverage.py
index 44fbc9f988..35f7f82b7e 100644
--- a/tests/web/routes/test_metrics_routes_coverage.py
+++ b/tests/web/routes/test_metrics_routes_coverage.py
@@ -230,20 +230,20 @@ class TestGetAvailableStrategies:
def test_returns_list(self):
result = get_available_strategies()
assert isinstance(result, list)
- assert len(result) > 10
+ assert len(result) >= 7
def test_each_strategy_has_name_and_description(self):
for s in get_available_strategies():
assert "name" in s
assert "description" in s
- def test_standard_strategy_present(self):
+ def test_source_based_strategy_present(self):
names = [s["name"] for s in get_available_strategies()]
- assert "standard" in names
+ assert "source-based" in names
- def test_smart_strategy_present(self):
+ def test_iterative_refinement_strategy_present(self):
names = [s["name"] for s in get_available_strategies()]
- assert "smart" in names
+ assert "iterative-refinement" in names
# =========================================================================
diff --git a/tests/web/services/test_notification_coverage.py b/tests/web/services/test_notification_coverage.py
index 4516bf807a..fca8767c21 100644
--- a/tests/web/services/test_notification_coverage.py
+++ b/tests/web/services/test_notification_coverage.py
@@ -337,7 +337,7 @@ class TestNotificationService:
)
svc = NotificationService()
- with pytest.raises(SendError):
+ with pytest.raises(ServiceError):
svc.send(
title="Test",
body="Body",