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: update news input validation tests for @require_json_body decorator (#2497)

LearningCircuita606fa0455ca
diff --git a/tests/news/test_news_input_validation.py b/tests/news/test_news_input_validation.py
index 50d9f472c5..c6a9412a92 100644
--- a/tests/news/test_news_input_validation.py
+++ b/tests/news/test_news_input_validation.py
@@ -2,7 +2,7 @@
Verifies:
- Limit parameter clamped to [1, 200]
-- JSON body validation returns 400 for missing/empty body
+- JSON body validation via @require_json_body decorator
"""
import inspect
@@ -27,27 +27,43 @@ class TestLimitClamping:
class TestJSONBodyValidation:
- """Verify endpoints reject missing/empty JSON body."""
+ """Verify endpoints reject missing/empty JSON body.
- def _check_json_guard(self, func_name):
+ These endpoints use the @require_json_body decorator which validates
+ that the request body is a JSON dict before the handler runs.
+ """
+
+ def _check_has_json_guard(self, func_name):
+ """Verify the endpoint is protected by @require_json_body."""
import local_deep_research.web.routes.news_routes as mod
func = getattr(mod, func_name)
+
+ # The decorator wraps the function, so check the decorator chain.
+ # inspect.getsource on the module-level function includes decorators.
source = inspect.getsource(func)
- assert "if data is None" in source or "if preferences is None" in source
- assert "Request body must be valid JSON" in source
+
+ # Either protected by @require_json_body decorator or inline check
+ has_decorator = "@require_json_body" in source
+ has_inline = (
+ "if data is None" in source or "if preferences is None" in source
+ )
+ assert has_decorator or has_inline, (
+ f"{func_name} is missing JSON body validation — "
+ f"add @require_json_body or an inline 'if data is None' check"
+ )
def test_create_subscription_validates_json(self):
- self._check_json_guard("create_subscription")
+ self._check_has_json_guard("create_subscription")
def test_update_subscription_validates_json(self):
- self._check_json_guard("update_subscription")
+ self._check_has_json_guard("update_subscription")
def test_submit_feedback_validates_json(self):
- self._check_json_guard("submit_feedback")
+ self._check_has_json_guard("submit_feedback")
def test_research_news_item_validates_json(self):
- self._check_json_guard("research_news_item")
+ self._check_has_json_guard("research_news_item")
def test_save_preferences_validates_json(self):
- self._check_json_guard("save_preferences")
+ self._check_has_json_guard("save_preferences")