~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(tests): narrow broad status-code tautologies in test_flask_api_routes.py (#4098)
LearningCircuitfef843abe9a2
diff --git a/tests/news/test_flask_api_routes.py b/tests/news/test_flask_api_routes.pyindex 4a63086e40..663e2635ce 100644--- a/tests/news/test_flask_api_routes.py+++ b/tests/news/test_flask_api_routes.py@@ -161,28 +161,38 @@ class TestNewsFeedEndpoint:"""Test feed endpoint with limit parameter."""response = client.get("/news/api/feed?limit=10")# May require auth or work depending on patch order- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_feed_with_use_cache_false(self, client):"""Test feed endpoint with use_cache=false."""response = client.get("/news/api/feed?use_cache=false")# Should require auth or return data- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_feed_with_strategy_parameter(self, client):"""Test feed endpoint with strategy parameter."""response = client.get("/news/api/feed?strategy=news_aggregation")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_feed_with_focus_parameter(self, client):"""Test feed endpoint with focus parameter."""response = client.get("/news/api/feed?focus=technology")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_feed_with_subscription_id(self, client):"""Test feed endpoint with subscription_id."""response = client.get("/news/api/feed?subscription_id=sub123")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Subscription CRUD Tests =============@@ -199,7 +209,9 @@ class TestCreateSubscription:content_type="application/json",)# Should return 400 or require auth- assert response.status_code in [302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_subscribe_with_all_parameters(self, client):"""Test subscribe with all optional parameters."""@@ -221,7 +233,9 @@ class TestCreateSubscription:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_subscribe_empty_json(self, client):"""Test subscribe with empty JSON."""@@ -230,7 +244,9 @@ class TestCreateSubscription:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_subscribe_custom_endpoint(self, client):"""Test subscribe with custom endpoint."""@@ -242,7 +258,9 @@ class TestCreateSubscription:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestGetSubscription:@@ -251,17 +269,23 @@ class TestGetSubscription:def test_get_subscription_null_id(self, client):"""Test getting subscription with null ID."""response = client.get("/news/api/subscriptions/null")- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_get_subscription_undefined_id(self, client):"""Test getting subscription with undefined ID."""response = client.get("/news/api/subscriptions/undefined")- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_get_subscription_valid_id(self, client):"""Test getting subscription with valid ID."""response = client.get("/news/api/subscriptions/sub123")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestUpdateSubscription:@@ -274,7 +298,9 @@ class TestUpdateSubscription:data="not json",content_type="application/json",)- assert response.status_code in [302, 400, 401, 403, 404, 405]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_update_subscription_partial_update(self, client):"""Test partial update of subscription."""@@ -283,7 +309,9 @@ class TestUpdateSubscription:json={"name": "Updated Name"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 405, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_update_subscription_all_fields(self, client):"""Test updating all subscription fields."""@@ -304,7 +332,9 @@ class TestUpdateSubscription:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 405, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestDeleteSubscription:@@ -313,7 +343,9 @@ class TestDeleteSubscription:def test_delete_nonexistent_subscription(self, client):"""Test deleting nonexistent subscription."""response = client.delete("/news/api/subscriptions/nonexistent123")- assert response.status_code in [200, 302, 401, 403, 404]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Voting and Feedback Tests =============@@ -329,7 +361,9 @@ class TestVoteOnNews:json={"vote": "up"},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_vote_missing_vote(self, client):"""Test voting with missing vote field."""@@ -338,7 +372,9 @@ class TestVoteOnNews:json={"card_id": "card123"},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_vote_upvote(self, client):"""Test upvoting a card."""@@ -347,7 +383,9 @@ class TestVoteOnNews:json={"card_id": "card123", "vote": "up"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_vote_downvote(self, client):"""Test downvoting a card."""@@ -356,7 +394,9 @@ class TestVoteOnNews:json={"card_id": "card123", "vote": "down"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestBatchFeedback:@@ -369,7 +409,9 @@ class TestBatchFeedback:json={"card_ids": []},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_batch_feedback_multiple_cards(self, client):"""Test batch feedback with multiple cards."""@@ -378,7 +420,9 @@ class TestBatchFeedback:json={"card_ids": ["card1", "card2", "card3"]},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_batch_feedback_no_json(self, client):"""Test batch feedback without JSON data."""@@ -386,7 +430,9 @@ class TestBatchFeedback:"/news/api/feedback/batch",content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestSubmitFeedback:@@ -399,7 +445,9 @@ class TestSubmitFeedback:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_submit_feedback_valid(self, client):"""Test submitting valid feedback."""@@ -408,7 +456,9 @@ class TestSubmitFeedback:json={"vote": "up"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Research Endpoint Tests =============@@ -424,7 +474,9 @@ class TestResearchNewsItem:json={"depth": "quick"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_research_detailed_depth(self, client):"""Test researching with detailed depth."""@@ -433,7 +485,9 @@ class TestResearchNewsItem:json={"depth": "detailed"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_research_report_depth(self, client):"""Test researching with report depth."""@@ -442,7 +496,9 @@ class TestResearchNewsItem:json={"depth": "report"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_research_default_depth(self, client):"""Test researching with default depth (no data)."""@@ -450,7 +506,9 @@ class TestResearchNewsItem:"/news/api/research/card123",content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Subscription History Tests =============@@ -462,12 +520,16 @@ class TestSubscriptionHistory:def test_get_history_default_limit(self, client):"""Test getting history with default limit."""response = client.get("/news/api/subscriptions/sub123/history")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_get_history_custom_limit(self, client):"""Test getting history with custom limit."""response = client.get("/news/api/subscriptions/sub123/history?limit=50")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Preferences Tests =============@@ -483,7 +545,9 @@ class TestSavePreferences:json={"preferences": {}},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_save_preferences_with_data(self, client):"""Test saving preferences with data."""@@ -498,7 +562,9 @@ class TestSavePreferences:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_save_preferences_no_json(self, client):"""Test saving preferences without JSON."""@@ -506,7 +572,9 @@ class TestSavePreferences:"/news/api/preferences",content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Categories Tests =============@@ -518,7 +586,9 @@ class TestGetCategories:def test_get_categories(self, client):"""Test getting categories."""response = client.get("/news/api/categories")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Scheduler Endpoint Tests =============@@ -530,7 +600,9 @@ class TestSchedulerStatus:def test_get_scheduler_status(self, client):"""Test getting scheduler status."""response = client.get("/news/api/scheduler/status")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestStartScheduler:@@ -539,7 +611,9 @@ class TestStartScheduler:def test_start_scheduler(self, client):"""Test starting scheduler."""response = client.post("/news/api/scheduler/start")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestStopScheduler:@@ -548,7 +622,9 @@ class TestStopScheduler:def test_stop_scheduler(self, client):"""Test stopping scheduler."""response = client.post("/news/api/scheduler/stop")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestCheckSubscriptionsNow:@@ -557,7 +633,9 @@ class TestCheckSubscriptionsNow:def test_check_subscriptions_now(self, client):"""Test triggering subscription check."""response = client.post("/news/api/scheduler/check-now")- assert response.status_code in [200, 302, 401, 403, 404, 500, 503]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestTriggerCleanup:@@ -566,7 +644,9 @@ class TestTriggerCleanup:def test_trigger_cleanup(self, client):"""Test triggering cleanup."""response = client.post("/news/api/scheduler/cleanup-now")- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestGetActiveUsers:@@ -575,7 +655,9 @@ class TestGetActiveUsers:def test_get_active_users(self, client):"""Test getting active users."""response = client.get("/news/api/scheduler/users")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestSchedulerStats:@@ -584,7 +666,9 @@ class TestSchedulerStats:def test_get_scheduler_stats(self, client):"""Test getting scheduler stats."""response = client.get("/news/api/scheduler/stats")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Overdue Subscriptions Tests =============@@ -596,7 +680,9 @@ class TestCheckOverdueSubscriptions:def test_check_overdue(self, client):"""Test checking overdue subscriptions."""response = client.post("/news/api/check-overdue")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Folder Management Tests =============@@ -608,7 +694,9 @@ class TestGetFolders:def test_get_folders(self, client):"""Test getting folders."""response = client.get("/news/api/subscription/folders")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestCreateFolder:@@ -621,7 +709,9 @@ class TestCreateFolder:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_create_folder_with_name(self, client):"""Test creating folder with name."""@@ -630,7 +720,9 @@ class TestCreateFolder:json={"name": "Test Folder"},content_type="application/json",)- assert response.status_code in [200, 201, 302, 400, 401, 403, 409, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_create_folder_with_description(self, client):"""Test creating folder with description."""@@ -639,7 +731,9 @@ class TestCreateFolder:json={"name": "Test Folder", "description": "A test folder"},content_type="application/json",)- assert response.status_code in [200, 201, 302, 400, 401, 403, 409, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestUpdateFolder:@@ -652,7 +746,9 @@ class TestUpdateFolder:json={"name": "Updated Folder"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestDeleteFolder:@@ -661,14 +757,18 @@ class TestDeleteFolder:def test_delete_folder(self, client):"""Test deleting folder."""response = client.delete("/news/api/subscription/folders/folder123")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_delete_folder_with_move_to(self, client):"""Test deleting folder with move_to parameter."""response = client.delete("/news/api/subscription/folders/folder123?move_to=other_folder")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Organized Subscriptions Tests =============@@ -680,7 +780,9 @@ class TestGetSubscriptionsOrganized:def test_get_subscriptions_organized(self, client):"""Test getting subscriptions organized by folder."""response = client.get("/news/api/subscription/subscriptions/organized")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestUpdateSubscriptionFolder:@@ -693,7 +795,9 @@ class TestUpdateSubscriptionFolder:json={"folder_id": "new_folder"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_update_subscription_refresh_interval(self, client):"""Test updating subscription refresh interval."""@@ -702,7 +806,9 @@ class TestUpdateSubscriptionFolder:json={"refresh_interval_minutes": 60},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Subscription Stats Tests =============@@ -714,7 +820,9 @@ class TestGetSubscriptionStats:def test_get_subscription_stats(self, client):"""Test getting subscription stats."""response = client.get("/news/api/subscription/stats")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Search History Tests =============@@ -726,7 +834,9 @@ class TestGetSearchHistory:def test_get_search_history(self, client):"""Test getting search history."""response = client.get("/news/api/search-history")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestAddSearchHistory:@@ -739,7 +849,9 @@ class TestAddSearchHistory:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_add_search_history_valid(self, client):"""Test adding valid search history."""@@ -752,7 +864,9 @@ class TestAddSearchHistory:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_add_search_history_minimal(self, client):"""Test adding minimal search history."""@@ -761,7 +875,9 @@ class TestAddSearchHistory:json={"query": "test search"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401class TestClearSearchHistory:@@ -770,7 +886,9 @@ class TestClearSearchHistory:def test_clear_search_history(self, client):"""Test clearing search history."""response = client.delete("/news/api/search-history")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Error Handler Tests =============@@ -808,7 +926,9 @@ class TestRunSubscriptionNow:def test_run_subscription_now(self, client):"""Test running subscription immediately."""response = client.post("/news/api/subscriptions/sub123/run")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Current User Subscriptions Tests =============@@ -820,7 +940,9 @@ class TestGetCurrentUserSubscriptions:def test_get_current_user_subscriptions(self, client):"""Test getting current user subscriptions."""response = client.get("/news/api/subscriptions/current")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Integration Tests with Mocking =============@@ -923,7 +1045,9 @@ class TestSchedulerWithMocks:mock_get_scheduler.return_value = mock_schedulerresponse = client.get("/news/api/scheduler/status")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401# ============= Edge Cases =============@@ -940,7 +1064,9 @@ class TestEdgeCases:json={"query": long_query},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_special_characters_in_query(self, client):"""Test subscription with special characters."""@@ -949,7 +1075,9 @@ class TestEdgeCases:json={"query": "test <script>alert('xss')</script>"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_unicode_in_query(self, client):"""Test subscription with unicode characters."""@@ -958,34 +1086,50 @@ class TestEdgeCases:json={"query": "测试 тест テスト"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_negative_limit(self, client):"""Test feed with negative limit."""response = client.get("/news/api/feed?limit=-1")- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_zero_limit(self, client):"""Test feed with zero limit."""response = client.get("/news/api/feed?limit=0")- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_very_large_limit(self, client):"""Test feed with very large limit."""response = client.get("/news/api/feed?limit=999999")- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_non_integer_limit(self, client):"""Test feed with non-integer limit."""response = client.get("/news/api/feed?limit=abc")- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_sql_injection_attempt(self, client):"""Test subscription ID with SQL injection attempt."""response = client.get("/news/api/subscriptions/'; DROP TABLE users; --")- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, (+ response.status_code+ ) # @login_required: unauthenticated request returns 401def test_path_traversal_attempt(self, client):"""Test subscription ID with path traversal attempt."""response = client.get("/news/api/subscriptions/../../etc/passwd")- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ # Werkzeug rejects the path traversal attempt before the route matches,+ # so we get 404 (no matching route) rather than 401 from @login_required.+ # Either way, the traversal never reaches a handler — which is what+ # this test exists to verify.+ assert response.status_code == 404, response.status_code