~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_settings_routes.py (#4134)
LearningCircuit5fed890106cd
diff --git a/tests/web/routes/test_settings_routes.py b/tests/web/routes/test_settings_routes.pyindex 34c08acc27..6b9d1efd4e 100644--- a/tests/web/routes/test_settings_routes.py+++ b/tests/web/routes/test_settings_routes.py@@ -173,27 +173,27 @@ class TestSettingsPageRoutes:"""Test settings page route exists."""response = client.get(f"{SETTINGS_PREFIX}/")# Should exist but may require auth- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_main_config_page_route_exists(self, client):"""Test main config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/main")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_collections_config_page_route_exists(self, client):"""Test collections config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/collections")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_api_keys_config_page_route_exists(self, client):"""Test API keys config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/api_keys")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_search_engines_config_page_route_exists(self, client):"""Test search engines config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/search_engines")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestSettingsApiRoutes:@@ -202,27 +202,27 @@ class TestSettingsApiRoutes:def test_api_get_all_settings_route_exists(self, client):"""Test /api GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_get_categories_route_exists(self, client):"""Test /api/categories GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/categories")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_get_types_route_exists(self, client):"""Test /api/types GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/types")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_get_ui_elements_route_exists(self, client):"""Test /api/ui_elements GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/ui_elements")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_get_warnings_route_exists(self, client):"""Test /api/warnings GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/warnings")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestSaveAllSettings:@@ -232,12 +232,12 @@ class TestSaveAllSettings:"""Test that save_all_settings requires POST method."""response = client.get(f"{SETTINGS_PREFIX}/save_all_settings")# GET should return 405 Method Not Allowed- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 405, response.status_codedef test_save_all_settings_requires_json(self, client):"""Test that save_all_settings requires JSON body."""response = client.post(f"{SETTINGS_PREFIX}/save_all_settings")- assert response.status_code in [302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestResetToDefaults:@@ -247,7 +247,7 @@ class TestResetToDefaults:"""Test that reset_to_defaults requires POST method."""response = client.get(f"{SETTINGS_PREFIX}/reset_to_defaults")# GET should return 405 Method Not Allowed- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 405, response.status_codeclass TestApiImportSettings:@@ -257,7 +257,7 @@ class TestApiImportSettings:"""Test that import_settings requires POST method."""response = client.get(f"{SETTINGS_PREFIX}/api/import")# GET should return 405 Method Not Allowed- assert response.status_code in [302, 401, 403, 405, 500]+ assert response.status_code == 401, response.status_codeclass TestAvailableModelsApi:@@ -266,7 +266,7 @@ class TestAvailableModelsApi:def test_api_available_models_route_exists(self, client):"""Test /api/available-models GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/available-models")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestAvailableSearchEnginesApi:@@ -275,7 +275,7 @@ class TestAvailableSearchEnginesApi:def test_api_available_search_engines_route_exists(self, client):"""Test /api/available-search-engines GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/available-search-engines")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestSearchFavoritesApi:@@ -284,12 +284,12 @@ class TestSearchFavoritesApi:def test_api_get_search_favorites_route_exists(self, client):"""Test /api/search-favorites GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/search-favorites")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_toggle_search_favorite_requires_post(self, client):"""Test /api/search-favorites/toggle requires POST."""response = client.get(f"{SETTINGS_PREFIX}/api/search-favorites/toggle")- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 401, response.status_codeclass TestOllamaStatusApi:@@ -298,7 +298,7 @@ class TestOllamaStatusApi:def test_api_ollama_status_route_exists(self, client):"""Test /api/ollama-status GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/ollama-status")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestRateLimitingApi:@@ -307,12 +307,12 @@ class TestRateLimitingApi:def test_api_rate_limiting_status_route_exists(self, client):"""Test /api/rate-limiting/status GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/rate-limiting/status")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_rate_limiting_cleanup_requires_post(self, client):"""Test /api/rate-limiting/cleanup requires POST."""response = client.get(f"{SETTINGS_PREFIX}/api/rate-limiting/cleanup")- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 401, response.status_codeclass TestBulkSettingsApi:@@ -321,7 +321,7 @@ class TestBulkSettingsApi:def test_api_get_bulk_settings_route_exists(self, client):"""Test /api/bulk GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/bulk")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestDataLocationApi:@@ -330,7 +330,7 @@ class TestDataLocationApi:def test_api_data_location_route_exists(self, client):"""Test /api/data-location GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/data-location")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestNotificationTestApi:@@ -339,7 +339,7 @@ class TestNotificationTestApi:def test_api_test_notification_requires_post(self, client):"""Test /api/notifications/test-url requires POST."""response = client.get(f"{SETTINGS_PREFIX}/api/notifications/test-url")- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 401, response.status_codeclass TestOpenFileLocation:@@ -348,7 +348,7 @@ class TestOpenFileLocation:def test_open_file_location_requires_post(self, client):"""Test open_file_location requires POST."""response = client.get(f"{SETTINGS_PREFIX}/open_file_location")- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 405, response.status_codeclass TestFixCorruptedSettings:@@ -357,7 +357,7 @@ class TestFixCorruptedSettings:def test_fix_corrupted_settings_requires_post(self, client):"""Test fix_corrupted_settings requires POST."""response = client.get(f"{SETTINGS_PREFIX}/fix_corrupted_settings")- assert response.status_code in [302, 401, 403, 405]+ assert response.status_code == 405, response.status_code# ============= Extended Tests for Phase 3.5 Coverage =============@@ -369,7 +369,7 @@ class TestSettingsApiExtended:def test_get_setting_by_key_route(self, client):"""Test /api/<key> GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/llm.provider")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codedef test_set_setting_by_key_route(self, client):"""Test /api/<key> PUT route exists."""@@ -378,7 +378,7 @@ class TestSettingsApiExtended:json={"value": "ollama"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 405, 500]+ assert response.status_code == 401, response.status_codeclass TestSaveAllSettingsExtended:@@ -391,7 +391,7 @@ class TestSaveAllSettingsExtended:json={"llm.provider": "ollama"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_save_all_settings_with_checkbox_values(self, client):"""Test save_all_settings with checkbox values."""@@ -403,7 +403,7 @@ class TestSaveAllSettingsExtended:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_save_all_settings_with_numeric_values(self, client):"""Test save_all_settings with numeric values."""@@ -415,7 +415,7 @@ class TestSaveAllSettingsExtended:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestSaveSettingsTraditionalPost:@@ -428,7 +428,7 @@ class TestSaveSettingsTraditionalPost:data={"llm.provider": "ollama"},content_type="application/x-www-form-urlencoded",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_save_settings_with_redirect(self, client):"""Test save_settings returns redirect."""@@ -438,7 +438,7 @@ class TestSaveSettingsTraditionalPost:content_type="application/x-www-form-urlencoded",follow_redirects=False,)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestResetToDefaultsExtended:@@ -451,7 +451,7 @@ class TestResetToDefaultsExtended:json={"confirm": True},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestExportSettings:@@ -460,7 +460,7 @@ class TestExportSettings:def test_api_export_settings_route_exists(self, client):"""Test /api/export GET route exists."""response = client.get(f"{SETTINGS_PREFIX}/api/export")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestImportSettingsExtended:@@ -473,7 +473,7 @@ class TestImportSettingsExtended:json={"settings": {"llm.provider": "ollama"}},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_import_settings_with_empty_json(self, client):"""Test import_settings with empty JSON."""@@ -482,7 +482,7 @@ class TestImportSettingsExtended:json={},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestValidateSettingExtended:@@ -654,17 +654,17 @@ class TestSettingsPageRoutesExtended:def test_llm_config_page_route_exists(self, client):"""Test LLM config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/llm")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_search_config_page_route_exists(self, client):"""Test search config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/search")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 404, response.status_codedef test_report_config_page_route_exists(self, client):"""Test report config page route exists."""response = client.get(f"{SETTINGS_PREFIX}/report")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 404, response.status_codeclass TestSettingsEdgeCases:@@ -677,7 +677,7 @@ class TestSettingsEdgeCases:json={"custom.prompt": "Test <script>alert('xss')</script>"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_save_settings_with_unicode(self, client):"""Test saving settings with unicode characters."""@@ -686,7 +686,7 @@ class TestSettingsEdgeCases:json={"custom.name": "测试设置 日本語"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_save_settings_with_very_long_value(self, client):"""Test saving settings with very long value."""@@ -695,12 +695,12 @@ class TestSettingsEdgeCases:json={"custom.text": "a" * 100000},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_get_invalid_setting_key(self, client):"""Test getting invalid setting key."""response = client.get(f"{SETTINGS_PREFIX}/api/nonexistent.setting.key")- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codedef test_save_settings_with_empty_body(self, client):"""Test saving settings with empty body."""@@ -709,7 +709,7 @@ class TestSettingsEdgeCases:json={},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestAvailableModelsApiExtended:@@ -720,7 +720,7 @@ class TestAvailableModelsApiExtended:response = client.get(f"{SETTINGS_PREFIX}/api/available-models?provider=ollama")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestNotificationTestApiExtended:@@ -733,7 +733,7 @@ class TestNotificationTestApiExtended:json={"service_url": "mailto://[email protected]"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_api_test_notification_missing_url(self, client):"""Test /api/notifications/test-url without URL."""@@ -742,7 +742,7 @@ class TestNotificationTestApiExtended:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestSearchFavoritesApiExtended:@@ -755,7 +755,7 @@ class TestSearchFavoritesApiExtended:json={"engine": "searxng"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestRateLimitingApiExtended:@@ -768,7 +768,7 @@ class TestRateLimitingApiExtended:json={"confirm": True},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestOpenFileLocationExtended:@@ -781,7 +781,7 @@ class TestOpenFileLocationExtended:json={"path": "/tmp"},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestFixCorruptedSettingsExtended:@@ -794,7 +794,7 @@ class TestFixCorruptedSettingsExtended:json={"confirm": True},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestCalculateWarningsExtended:@@ -884,7 +884,7 @@ class TestNonEditableSettingsProtection:follow_redirects=True,)# Should redirect/succeed — non-editable key is silently skipped- assert response.status_code in [200, 302]+ assert response.status_code == 200, response.status_code# Verify the non-editable setting was NOT changedverify_response = authenticated_client.get(