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: align route tests with @login_required additions from #3129 (#3681)

LearningCircuitebb27ed86362
diff --git a/tests/news/test_flask_api_coverage.py b/tests/news/test_flask_api_coverage.py
index f038782958..9f74f8d5f4 100644
--- a/tests/news/test_flask_api_coverage.py
+++ b/tests/news/test_flask_api_coverage.py
@@ -686,6 +686,7 @@ class TestSavePreferences:
class TestGetCategories:
def test_success(self, client):
+ _auth(client)
with patch(
f"{MODULE}.api.get_news_categories",
return_value={"categories": ["tech"]},
@@ -694,6 +695,7 @@ class TestGetCategories:
assert resp.status_code == 200
def test_exception(self, client):
+ _auth(client)
with patch(
f"{MODULE}.api.get_news_categories",
side_effect=RuntimeError("fail"),
diff --git a/tests/news/test_flask_api_deep_coverage.py b/tests/news/test_flask_api_deep_coverage.py
index 09902dc231..011b768fa5 100644
--- a/tests/news/test_flask_api_deep_coverage.py
+++ b/tests/news/test_flask_api_deep_coverage.py
@@ -1081,31 +1081,41 @@ class TestSavePreferences:
class TestGetCategories:
- """Tests for the /categories endpoint (no login required)."""
+ """Tests for the /categories endpoint."""
- def test_returns_categories(self, client):
+ def test_returns_categories(self, authed_client):
mock_result = {
"categories": [
{"name": "tech", "count": 10},
{"name": "science", "count": 5},
]
}
- with patch(
- "local_deep_research.news.flask_api.api.get_news_categories",
- return_value=mock_result,
- ) as mock_cats:
- resp = client.get("/news/api/categories")
+ patches = _auth_patches()
+ with (
+ patches["db_manager"] as mock_db,
+ patch(
+ "local_deep_research.news.flask_api.api.get_news_categories",
+ return_value=mock_result,
+ ) as mock_cats,
+ ):
+ mock_db.is_user_connected.return_value = True
+ resp = authed_client.get("/news/api/categories")
assert resp.status_code == 200
data = resp.get_json()
assert len(data["categories"]) == 2
mock_cats.assert_called_once()
- def test_exception_returns_500(self, client):
- with patch(
- "local_deep_research.news.flask_api.api.get_news_categories",
- side_effect=RuntimeError("fail"),
+ def test_exception_returns_500(self, authed_client):
+ patches = _auth_patches()
+ with (
+ patches["db_manager"] as mock_db,
+ patch(
+ "local_deep_research.news.flask_api.api.get_news_categories",
+ side_effect=RuntimeError("fail"),
+ ),
):
- resp = client.get("/news/api/categories")
+ mock_db.is_user_connected.return_value = True
+ resp = authed_client.get("/news/api/categories")
assert resp.status_code == 500
diff --git a/tests/news/test_web_blueprint.py b/tests/news/test_web_blueprint.py
index 6d57c2b067..7f22ee97a4 100644
--- a/tests/news/test_web_blueprint.py
+++ b/tests/news/test_web_blueprint.py
@@ -15,6 +15,28 @@ from unittest.mock import MagicMock, patch
from flask import Flask
+class _AlwaysAuthenticated:
+ def __contains__(self, key):
+ return True
+
+ def __getitem__(self, key):
+ return "testuser"
+
+
[email protected](autouse=True)
+def _bypass_login_required(monkeypatch):
+ # These tests exercise route logic, not auth. PR #3129 added
+ # @login_required to news routes; auth itself is covered in tests/web/auth/.
+ monkeypatch.setattr(
+ "local_deep_research.web.auth.decorators.session",
+ _AlwaysAuthenticated(),
+ )
+ monkeypatch.setattr(
+ "local_deep_research.web.auth.decorators.db_manager.is_user_connected",
+ lambda *args, **kwargs: True,
+ )
+
+
@pytest.fixture
def app():
"""Create a Flask app for testing."""
diff --git a/tests/news/test_web_routes_comprehensive.py b/tests/news/test_web_routes_comprehensive.py
index 1cd3aeec2e..c1a1b91a0a 100644
--- a/tests/news/test_web_routes_comprehensive.py
+++ b/tests/news/test_web_routes_comprehensive.py
@@ -5,6 +5,30 @@ Tests create_news_blueprint, page routes, and load_user_settings.
from unittest.mock import patch
+import pytest
+
+
+class _AlwaysAuthenticated:
+ def __contains__(self, key):
+ return True
+
+ def __getitem__(self, key):
+ return "testuser"
+
+
[email protected](autouse=True)
+def _bypass_login_required(monkeypatch):
+ # These tests exercise route logic, not auth. PR #3129 added
+ # @login_required to news routes; auth itself is covered in tests/web/auth/.
+ monkeypatch.setattr(
+ "local_deep_research.web.auth.decorators.session",
+ _AlwaysAuthenticated(),
+ )
+ monkeypatch.setattr(
+ "local_deep_research.web.auth.decorators.db_manager.is_user_connected",
+ lambda *args, **kwargs: True,
+ )
+
class TestCreateNewsBlueprint:
"""Tests for create_news_blueprint function."""
diff --git a/tests/web/routes/test_research_routes_config.py b/tests/web/routes/test_research_routes_config.py
index 94d11f0c24..86321550b9 100644
--- a/tests/web/routes/test_research_routes_config.py
+++ b/tests/web/routes/test_research_routes_config.py
@@ -135,13 +135,14 @@ class TestSaveRawConfig:
class TestGetUploadLimits:
"""Tests for /api/upload/limits endpoint."""
- def test_accessible_without_authentication(self, client):
- """Upload limits are public config, no auth needed."""
+ def test_requires_authentication(self, client):
response = client.get(f"{RESEARCH_PREFIX}/api/config/limits")
- assert response.status_code == 200
+ assert response.status_code == 401
- def test_returns_upload_limits(self, client):
- response = client.get(f"{RESEARCH_PREFIX}/api/config/limits")
+ def test_returns_upload_limits(self, authenticated_client):
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/api/config/limits"
+ )
assert response.status_code == 200
data = response.get_json()
assert "max_file_size" in data
@@ -151,7 +152,9 @@ class TestGetUploadLimits:
assert isinstance(data["max_files"], int)
assert isinstance(data["allowed_mime_types"], list)
- def test_mime_types_include_pdf(self, client):
- response = client.get(f"{RESEARCH_PREFIX}/api/config/limits")
+ def test_mime_types_include_pdf(self, authenticated_client):
+ response = authenticated_client.get(
+ f"{RESEARCH_PREFIX}/api/config/limits"
+ )
data = response.get_json()
assert "application/pdf" in data["allowed_mime_types"]