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 28 deep coverage tests for library_routes.py (#2793)

LearningCircuit2c883631681c
diff --git a/tests/news/test_flask_api_coverage.py b/tests/news/test_flask_api_coverage.py
index 978abf2444..07fcee0ba7 100644
--- a/tests/news/test_flask_api_coverage.py
+++ b/tests/news/test_flask_api_coverage.py
@@ -60,6 +60,7 @@ class TestSubscribe:
"/news/api/subscribe", json={"subscription_type": "search"}
)
assert resp.status_code == 400
+ assert "required" in resp.get_json()["error"]
def test_invalid_json_returns_400(self, client):
_auth(client)
@@ -227,12 +228,14 @@ class TestSubmitFeedback:
):
resp = client.post("/news/api/feedback/card1", json={"vote": "up"})
assert resp.status_code == 200
+ assert resp.get_json()["status"] == "recorded"
def test_missing_vote_returns_400(self, client):
_auth(client)
with patch(f"{MODULE}.get_user_id", return_value="testuser"):
resp = client.post("/news/api/feedback/card1", json={})
assert resp.status_code == 400
+ assert "vote" in resp.get_json()["error"].lower()
def test_not_found_returns_404(self, client):
_auth(client)
@@ -334,6 +337,7 @@ class TestGetNewsFeed:
):
resp = client.get("/news/api/feed")
assert resp.status_code == 200
+ assert len(resp.get_json()["news_items"]) == 1
def test_error_in_result_returns_500(self, client):
_auth(client)
@@ -504,6 +508,7 @@ class TestGetFolders:
):
resp = client.get("/news/api/subscription/folders")
assert resp.status_code == 200
+ assert resp.get_json()[0]["name"] == "Tech"
class TestDeleteSubscription:
@@ -512,6 +517,7 @@ class TestDeleteSubscription:
with patch(f"{MODULE}.api.delete_subscription", return_value=True):
resp = client.delete("/news/api/subscriptions/s1")
assert resp.status_code == 200
+ assert resp.get_json()["status"] == "success"
def test_not_found(self, client):
_auth(client)
@@ -538,6 +544,7 @@ class TestGetSubscription:
):
resp = client.get("/news/api/subscriptions/s1")
assert resp.status_code == 200
+ assert resp.get_json()["id"] == "s1"
def test_null_id_returns_400(self, client):
_auth(client)
@@ -708,6 +715,7 @@ class TestSubscriptionStats:
):
resp = client.get("/news/api/subscription/stats")
assert resp.status_code == 200
+ assert resp.get_json()["total"] == 5
class TestGetSubscriptionsOrganized:
@@ -725,6 +733,7 @@ class TestGetSubscriptionsOrganized:
):
resp = client.get("/news/api/subscription/subscriptions/organized")
assert resp.status_code == 200
+ assert "General" in resp.get_json()
SCHED_MOD = "local_deep_research.news.subscription_manager.scheduler"
@@ -749,6 +758,9 @@ class TestSchedulerStatus:
):
resp = client.get("/news/api/scheduler/status")
assert resp.status_code == 200
+ data = resp.get_json()
+ assert data["is_running"] is True
+ assert data["active_users"] == 1
class TestSchedulerStats:
@@ -764,6 +776,8 @@ class TestSchedulerStats:
):
resp = client.get("/news/api/scheduler/stats")
assert resp.status_code == 200
+ data = resp.get_json()
+ assert data["scheduler_running"] is True
class TestGetActiveUsers:
@@ -771,7 +785,7 @@ class TestGetActiveUsers:
_auth(client)
ms = MagicMock()
ms.get_user_sessions_summary.return_value = [
- {"user_id": "testuser", "last_activity": "2026-01-01"}
+ {"user_id": "testuser", "last_activity": "2026-01-01"},
]
with (
patch(f"{MODULE}.get_env_setting", return_value=False),
@@ -779,6 +793,9 @@ class TestGetActiveUsers:
):
resp = client.get("/news/api/scheduler/users")
assert resp.status_code == 200
+ data = resp.get_json()
+ assert data["active_users"] == 1
+ assert data["users"][0]["user_id"] == "testuser"
class TestErrorHandlers:
@@ -786,19 +803,19 @@ class TestErrorHandlers:
from local_deep_research.news.flask_api import bad_request
with app.app_context():
- _, status = bad_request(None)
+ resp, status = bad_request(None)
assert status == 400
def test_not_found_handler(self, app):
from local_deep_research.news.flask_api import not_found
with app.app_context():
- _, status = not_found(None)
+ resp, status = not_found(None)
assert status == 404
def test_internal_error_handler(self, app):
from local_deep_research.news.flask_api import internal_error
with app.app_context():
- _, status = internal_error(None)
+ resp, status = internal_error(None)
assert status == 500