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.

test: add coverage tests for research routes and web API

LearningCircuit5caaa3d04959
diff --git a/tests/web/routes/test_history_routes.py b/tests/web/routes/test_history_routes.py
index 903b8c192e..e29f3e8577 100644
--- a/tests/web/routes/test_history_routes.py
+++ b/tests/web/routes/test_history_routes.py
@@ -343,21 +343,77 @@ class TestGetReport:
def test_returns_404_for_nonexistent(self, authenticated_client):
"""Should return 404 for non-existent research."""
- # The endpoint uses the session from Flask session, we need to mock that
- # as well as the database layer
- response = authenticated_client.get(
- f"{HISTORY_PREFIX}/report/nonexistent-id"
- )
- # May return 404 or 500 depending on database state
- assert response.status_code in [404, 500]
+ with patch(
+ "src.local_deep_research.web.routes.history_routes.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ mock_query = MagicMock()
+ mock_query.filter_by.return_value.first.return_value = None
+ mock_session.query.return_value = mock_query
+
+ response = authenticated_client.get(
+ f"{HISTORY_PREFIX}/report/nonexistent-id"
+ )
+
+ assert response.status_code == 404
+ data = response.get_json()
+ assert data["status"] == "error"
def test_returns_report_for_existing(self, authenticated_client):
"""Should return report for existing research."""
- # This test verifies the endpoint exists and requires auth
- # Full integration testing would require more complex setup
- response = authenticated_client.get(f"{HISTORY_PREFIX}/report/test-id")
- # May return 404 (not found) or 500 (db issue) - both are acceptable
- assert response.status_code in [200, 404, 500]
+ with patch(
+ "src.local_deep_research.web.routes.history_routes.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ mock_research = MagicMock()
+ mock_research.id = "test-id"
+ mock_research.query = "Test query"
+ mock_research.mode = "quick"
+ mock_research.created_at = "2024-01-01T10:00:00"
+ mock_research.completed_at = "2024-01-01T10:05:00"
+ mock_research.duration_seconds = 300
+
+ mock_query = MagicMock()
+ mock_query.filter_by.return_value.first.return_value = mock_research
+ mock_session.query.return_value = mock_query
+
+ with patch(
+ "src.local_deep_research.web.auth.decorators.current_user"
+ ) as mock_current_user:
+ mock_current_user.return_value = "testuser"
+
+ with patch(
+ "src.local_deep_research.storage.get_report_storage"
+ ) as mock_storage_factory:
+ mock_storage = MagicMock()
+ mock_storage.get_report_with_metadata.return_value = {
+ "content": "# Test Report\n\nThis is test content.",
+ "metadata": {"key": "value"},
+ }
+ mock_storage_factory.return_value = mock_storage
+
+ response = authenticated_client.get(
+ f"{HISTORY_PREFIX}/report/test-id"
+ )
+
+ assert response.status_code == 200
+ data = response.get_json()
+ assert data["status"] == "success"
+ assert "content" in data
class TestGetMarkdown:
@@ -370,13 +426,46 @@ class TestGetMarkdown:
def test_returns_markdown_for_existing(self, authenticated_client):
"""Should return markdown for existing research."""
- # This test verifies the endpoint exists and requires auth
- # Full integration testing would require more complex setup
- response = authenticated_client.get(
- f"{HISTORY_PREFIX}/markdown/test-id"
- )
- # May return 404 (not found) or 500 (db issue) - both are acceptable
- assert response.status_code in [200, 404, 500]
+ with patch(
+ "src.local_deep_research.web.routes.history_routes.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ mock_research = MagicMock()
+ mock_research.id = "test-id"
+
+ mock_query = MagicMock()
+ mock_query.filter_by.return_value.first.return_value = mock_research
+ mock_session.query.return_value = mock_query
+
+ with patch(
+ "src.local_deep_research.web.auth.decorators.current_user"
+ ) as mock_current_user:
+ mock_current_user.return_value = "testuser"
+
+ with patch(
+ "src.local_deep_research.storage.get_report_storage"
+ ) as mock_storage_factory:
+ mock_storage = MagicMock()
+ mock_storage.get_report.return_value = (
+ "# Test Research\n\nThis is the markdown content."
+ )
+ mock_storage_factory.return_value = mock_storage
+
+ response = authenticated_client.get(
+ f"{HISTORY_PREFIX}/markdown/test-id"
+ )
+
+ assert response.status_code == 200
+ data = response.get_json()
+ assert data["status"] == "success"
+ assert "content" in data
class TestGetResearchLogs:
diff --git a/tests/web/routes/test_research_routes.py b/tests/web/routes/test_research_routes.py
new file mode 100644
index 0000000000..40539aa3f1
--- /dev/null
+++ b/tests/web/routes/test_research_routes.py
@@ -0,0 +1,312 @@
+"""Tests for research_routes module - Research page and API endpoints."""
+
+from unittest.mock import patch
+
+import pytest
+
+
+# Research routes are registered under root level
+RESEARCH_PREFIX = ""
+
+
+def client():
+ """Create a test client without authentication."""
+ from flask import Flask
+
+ # Create a minimal Flask app for testing
+ app = Flask(__name__)
+ app.config["TESTING"] = True
+ app.config["SECRET_KEY"] = "test-secret-key"
+ app.config["WTF_CSRF_ENABLED"] = False
+
+ return app.test_client()
+
+
+def authenticated_client():
+ """Create a test client with authentication mocked."""
+ from flask import Flask
+
+ # Patch decorators before importing routes
+ with patch(
+ "src.local_deep_research.web.auth.decorators.login_required",
+ lambda f: f,
+ ):
+ with patch(
+ "src.local_deep_research.web.utils.rate_limiter.limiter"
+ ) as mock_limiter:
+ mock_limiter.exempt = lambda f: f
+ mock_limiter.limit = lambda *args, **kwargs: lambda f: f
+
+ # Import routes with patched decorators
+ import importlib
+ import src.local_deep_research.web.routes.research_routes as research_module
+
+ importlib.reload(research_module)
+
+ app = Flask(__name__)
+ app.config["TESTING"] = True
+ app.config["SECRET_KEY"] = "test-secret-key"
+ app.config["WTF_CSRF_ENABLED"] = False
+
+ # Register blueprint
+ app.register_blueprint(research_module.research_bp)
+
+ with app.test_client() as client:
+ with client.session_transaction() as sess:
+ sess["username"] = "testuser"
+ yield client
+
+
+class TestProgressPage:
+ """Tests for /progress/<research_id> endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/progress/test-id")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return progress page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Progress</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/progress/test-id"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("pages/progress.html")
+
+
+class TestResearchDetailsPage:
+ """Tests for /details/<research_id> endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/details/test-id")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return details page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Details</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/details/test-id"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("pages/details.html")
+
+
+class TestResultsPage:
+ """Tests for /results/<research_id> endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/results/test-id")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return results page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Results</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/results/test-id"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("pages/results.html")
+
+
+class TestHistoryPage:
+ """Tests for /history endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/history")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return history page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>History</html>"
+ response = authenticated_client.get(f"{RESEARCH_PREFIX}/history")
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("pages/history.html")
+
+
+class TestSettingsPage:
+ """Tests for /settings endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/settings")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return settings page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Settings</html>"
+ response = authenticated_client.get(f"{RESEARCH_PREFIX}/settings")
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("settings_dashboard.html")
+
+
+class TestMainConfigPage:
+ """Tests for /settings/main endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/settings/main")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return main config page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Main Config</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/settings/main"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("main_config.html")
+
+
+class TestCollectionsConfigPage:
+ """Tests for /settings/collections endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/settings/collections")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return collections config page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Collections</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/settings/collections"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("collections_config.html")
+
+
+class TestApiKeysConfigPage:
+ """Tests for /settings/api_keys endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/settings/api_keys")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return API keys config page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>API Keys</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/settings/api_keys"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("api_keys_config.html")
+
+
+class TestSearchEnginesConfigPage:
+ """Tests for /settings/search_engines endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/settings/search_engines")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return search engines config page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>Search Engines</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/settings/search_engines"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("search_engines_config.html")
+
+
+class TestLlmConfigPage:
+ """Tests for /settings/llm endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.get(f"{RESEARCH_PREFIX}/settings/llm")
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_page_when_authenticated(self, authenticated_client):
+ """Should return LLM config page when authenticated."""
+ with patch(
+ "src.local_deep_research.web.routes.research_routes.render_template_with_defaults"
+ ) as mock_render:
+ mock_render.return_value = "<html>LLM Config</html>"
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/settings/llm"
+ )
+ assert response.status_code == 200
+ mock_render.assert_called_once_with("llm_config.html")
+
+
+class TestRedirectStatic:
+ """Tests for /redirect-static/<path> endpoint."""
+
+ def test_redirects_to_static(self, authenticated_client):
+ """Should redirect to static URL."""
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/redirect-static/js/app.js"
+ )
+ # Should return a redirect response
+ assert response.status_code == 302
+
+
+class TestStartResearchApi:
+ """Tests for /api/start_research endpoint."""
+
+ def test_requires_authentication(self, client):
+ """Should require authentication."""
+ response = client.post(
+ f"{RESEARCH_PREFIX}/api/start_research",
+ json={"query": "test query"},
+ )
+ assert response.status_code in [401, 302, 404]
+
+ def test_returns_401_without_session(self, authenticated_client):
+ """Should return 401 when session has no username."""
+ # Clear the session username
+ with authenticated_client.session_transaction() as sess:
+ sess.pop("username", None)
+
+ response = authenticated_client.post(
+ f"{RESEARCH_PREFIX}/api/start_research",
+ json={"query": "test query"},
+ )
+ # Expects 401 since username is not in session
+ assert response.status_code == 401
+
+ def test_requires_json_body(self, authenticated_client):
+ """Should require JSON body."""
+ response = authenticated_client.post(
+ f"{RESEARCH_PREFIX}/api/start_research",
+ data="not json",
+ content_type="text/plain",
+ )
+ # Should return error for non-JSON body
+ assert response.status_code in [400, 415, 500]
diff --git a/tests/web/test_api.py b/tests/web/test_api.py
new file mode 100644
index 0000000000..355bddf39e
--- /dev/null
+++ b/tests/web/test_api.py
@@ -0,0 +1,269 @@
+"""Tests for web/api.py module - REST API endpoints."""
+
+from unittest.mock import patch, MagicMock
+import time
+
+import pytest
+
+
+def client():
+ """Create a test client for the API."""
+ from flask import Flask
+ from src.local_deep_research.web.api import api_blueprint
+
+ app = Flask(__name__)
+ app.config["TESTING"] = True
+ app.config["SECRET_KEY"] = "test-secret-key"
+
+ app.register_blueprint(api_blueprint)
+
+ return app.test_client()
+
+
+def authenticated_client():
+ """Create a test client with authentication mocked."""
+ from flask import Flask
+ from src.local_deep_research.web.api import api_blueprint
+
+ app = Flask(__name__)
+ app.config["TESTING"] = True
+ app.config["SECRET_KEY"] = "test-secret-key"
+
+ app.register_blueprint(api_blueprint)
+
+ with app.test_client() as client:
+ with client.session_transaction() as sess:
+ sess["username"] = "testuser"
+ yield client
+
+
+class TestHealthCheck:
+ """Tests for /api/v1/health endpoint."""
+
+ def test_returns_ok_status(self, client):
+ """Should return ok status."""
+ response = client.get("/api/v1/health")
+ assert response.status_code == 200
+ data = response.get_json()
+ assert data["status"] == "ok"
+ assert data["message"] == "API is running"
+ assert "timestamp" in data
+
+ def test_returns_timestamp(self, client):
+ """Should return a valid timestamp."""
+ response = client.get("/api/v1/health")
+ data = response.get_json()
+ # Timestamp should be close to current time
+ assert abs(data["timestamp"] - time.time()) < 5
+
+
+class TestApiDocumentation:
+ """Tests for /api/v1/ endpoint."""
+
+ def test_returns_api_docs(self, authenticated_client):
+ """Should return API documentation."""
+ with patch(
+ "src.local_deep_research.web.api.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ with patch(
+ "src.local_deep_research.web.api.get_settings_manager"
+ ) as mock_settings:
+ mock_manager = MagicMock()
+ mock_manager.get_setting.side_effect = lambda key, default: {
+ "app.enable_api": True,
+ "app.api_rate_limit": 60,
+ }.get(key, default)
+ mock_settings.return_value = mock_manager
+
+ response = authenticated_client.get("/api/v1/")
+ assert response.status_code == 200
+ data = response.get_json()
+ assert data["api_version"] == "v1"
+ assert "endpoints" in data
+ assert len(data["endpoints"]) >= 1
+
+ def test_lists_available_endpoints(self, authenticated_client):
+ """Should list all available endpoints."""
+ with patch(
+ "src.local_deep_research.web.api.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ with patch(
+ "src.local_deep_research.web.api.get_settings_manager"
+ ) as mock_settings:
+ mock_manager = MagicMock()
+ mock_manager.get_setting.side_effect = lambda key, default: {
+ "app.enable_api": True,
+ "app.api_rate_limit": 60,
+ }.get(key, default)
+ mock_settings.return_value = mock_manager
+
+ response = authenticated_client.get("/api/v1/")
+ data = response.get_json()
+
+ # Check that key endpoints are documented
+ endpoints = data["endpoints"]
+ paths = [ep["path"] for ep in endpoints]
+ assert "/api/v1/quick_summary" in paths
+ assert "/api/v1/generate_report" in paths
+ assert "/api/v1/analyze_documents" in paths
+
+
+class TestApiAccessControl:
+ """Tests for API access control decorator."""
+
+ def test_returns_403_when_api_disabled(self, authenticated_client):
+ """Should return 403 when API is disabled."""
+ with patch(
+ "src.local_deep_research.web.api.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ with patch(
+ "src.local_deep_research.web.api.get_settings_manager"
+ ) as mock_settings:
+ mock_manager = MagicMock()
+ mock_manager.get_setting.side_effect = lambda key, default: {
+ "app.enable_api": False, # API disabled
+ "app.api_rate_limit": 60,
+ }.get(key, default)
+ mock_settings.return_value = mock_manager
+
+ response = authenticated_client.get("/api/v1/")
+ assert response.status_code == 403
+ data = response.get_json()
+ assert "disabled" in data["error"].lower()
+
+
+class TestRateLimiting:
+ """Tests for rate limiting functionality."""
+
+ def test_allows_requests_under_limit(self, authenticated_client):
+ """Should allow requests under the rate limit."""
+ with patch(
+ "src.local_deep_research.web.api.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ with patch(
+ "src.local_deep_research.web.api.get_settings_manager"
+ ) as mock_settings:
+ mock_manager = MagicMock()
+ mock_manager.get_setting.side_effect = lambda key, default: {
+ "app.enable_api": True,
+ "app.api_rate_limit": 100, # High limit
+ }.get(key, default)
+ mock_settings.return_value = mock_manager
+
+ # Clear rate limit data
+ from src.local_deep_research.web.api import rate_limit_data
+
+ rate_limit_data.clear()
+
+ # Make a few requests
+ for _ in range(3):
+ response = authenticated_client.get("/api/v1/")
+ assert response.status_code == 200
+
+
+class TestQuickSummaryTestEndpoint:
+ """Tests for /api/v1/quick_summary_test endpoint."""
+
+ def test_requires_query_parameter(self, authenticated_client):
+ """Should require query parameter."""
+ with patch(
+ "src.local_deep_research.web.api.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ with patch(
+ "src.local_deep_research.web.api.get_settings_manager"
+ ) as mock_settings:
+ mock_manager = MagicMock()
+ mock_manager.get_setting.side_effect = lambda key, default: {
+ "app.enable_api": True,
+ "app.api_rate_limit": 60,
+ }.get(key, default)
+ mock_settings.return_value = mock_manager
+
+ # Clear rate limit data
+ from src.local_deep_research.web.api import rate_limit_data
+
+ rate_limit_data.clear()
+
+ response = authenticated_client.post(
+ "/api/v1/quick_summary_test",
+ json={}, # No query parameter
+ )
+ assert response.status_code == 400
+ data = response.get_json()
+ assert "query" in data["error"].lower()
+
+ def test_returns_400_for_empty_body(self, authenticated_client):
+ """Should return 400 for empty body."""
+ with patch(
+ "src.local_deep_research.web.api.get_user_db_session"
+ ) as mock_session_ctx:
+ mock_session = MagicMock()
+ mock_session_ctx.return_value.__enter__ = MagicMock(
+ return_value=mock_session
+ )
+ mock_session_ctx.return_value.__exit__ = MagicMock(
+ return_value=None
+ )
+
+ with patch(
+ "src.local_deep_research.web.api.get_settings_manager"
+ ) as mock_settings:
+ mock_manager = MagicMock()
+ mock_manager.get_setting.side_effect = lambda key, default: {
+ "app.enable_api": True,
+ "app.api_rate_limit": 60,
+ }.get(key, default)
+ mock_settings.return_value = mock_manager
+
+ # Clear rate limit data
+ from src.local_deep_research.web.api import rate_limit_data
+
+ rate_limit_data.clear()
+
+ response = authenticated_client.post(
+ "/api/v1/quick_summary_test",
+ content_type="application/json",
+ )
+ assert response.status_code == 400