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(tests): patch db_manager in all before_request handlers to prevent flaky 302 (#3472)

LearningCircuit2776b8592224
diff --git a/tests/research_library/search/routes/test_search_routes.py b/tests/research_library/search/routes/test_search_routes.py
index 4298be0376..8b3cb1bfc9 100644
--- a/tests/research_library/search/routes/test_search_routes.py
+++ b/tests/research_library/search/routes/test_search_routes.py
@@ -20,10 +20,25 @@ def auth_client(app):
# Mock db_manager.connections to have an entry for testuser
mock_connections = {"testuser": MagicMock()}
- with patch(
- "local_deep_research.web.auth.decorators.db_manager"
- ) as mock_db_manager:
+ # Patch db_manager in all modules that import it directly, so that
+ # before_request handlers (session_cleanup, database_middleware) also
+ # see the mock and don't clear the session or fail to initialise.
+ with (
+ patch(
+ "local_deep_research.web.auth.decorators.db_manager"
+ ) as mock_db_manager,
+ patch(
+ "local_deep_research.web.auth.session_cleanup.db_manager",
+ mock_db_manager,
+ ),
+ patch(
+ "local_deep_research.web.auth.database_middleware.db_manager",
+ mock_db_manager,
+ ),
+ ):
mock_db_manager.connections = mock_connections
+ mock_db_manager.is_user_connected.return_value = True
+ mock_db_manager.has_encryption = False
client = app.test_client()
with client.session_transaction() as sess: