~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_rag_routes.py (#4133)
LearningCircuit93368e06504b
diff --git a/tests/research_library/routes/test_rag_routes.py b/tests/research_library/routes/test_rag_routes.pyindex 1426535d9e..b793c49780 100644--- a/tests/research_library/routes/test_rag_routes.py+++ b/tests/research_library/routes/test_rag_routes.py@@ -551,7 +551,7 @@ class TestRagApiRoutes:with app.test_client() as client:response = client.get("/library/api/rag/settings")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_test_embedding_route(self):"""Test /api/rag/test-embedding POST endpoint exists."""@@ -571,7 +571,7 @@ class TestRagApiRoutes:json={"text": "test text"},content_type="application/json",)- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_available_models_route(self):"""Test /api/rag/models GET endpoint exists."""@@ -587,7 +587,7 @@ class TestRagApiRoutes:with app.test_client() as client:response = client.get("/library/api/rag/models")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_index_info_route(self):"""Test /api/rag/info GET endpoint exists."""@@ -603,7 +603,7 @@ class TestRagApiRoutes:with app.test_client() as client:response = client.get("/library/api/rag/info")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_rag_stats_route(self):"""Test /api/rag/stats GET endpoint exists."""@@ -619,7 +619,7 @@ class TestRagApiRoutes:with app.test_client() as client:response = client.get("/library/api/rag/stats")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_supported_formats_route(self):"""Test /api/config/supported-formats GET endpoint exists."""@@ -636,7 +636,7 @@ class TestRagApiRoutes:with app.test_client() as client:response = client.get("/library/api/config/supported-formats")# 500 is acceptable in isolated test (login redirect fails without auth blueprint)- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestRagIndexRoutes:@@ -660,7 +660,7 @@ class TestRagIndexRoutes:json={"document_id": "doc123"},content_type="application/json",)- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_remove_document_route(self):"""Test /api/rag/remove-document POST endpoint exists."""@@ -680,7 +680,7 @@ class TestRagIndexRoutes:json={"document_id": "doc123"},content_type="application/json",)- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_index_research_route(self):"""Test /api/rag/index-research POST endpoint exists."""@@ -700,7 +700,7 @@ class TestRagIndexRoutes:json={"research_id": "research123"},content_type="application/json",)- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_index_all_route(self):"""Test /api/rag/index-all GET endpoint exists."""@@ -716,7 +716,7 @@ class TestRagIndexRoutes:with app.test_client() as client:response = client.get("/library/api/rag/index-all")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestRagCollectionRoutes:@@ -736,7 +736,7 @@ class TestRagCollectionRoutes:with app.test_client() as client:response = client.get("/library/api/collections")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_create_collection_route(self):"""Test /api/collections POST endpoint exists."""@@ -756,7 +756,7 @@ class TestRagCollectionRoutes:json={"name": "Test Collection"},content_type="application/json",)- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_update_collection_route(self):"""Test /api/collections/<id> PUT endpoint exists."""@@ -776,7 +776,7 @@ class TestRagCollectionRoutes:json={"name": "Updated Collection"},content_type="application/json",)- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codeclass TestRagPageRoutes:@@ -796,7 +796,7 @@ class TestRagPageRoutes:with app.test_client() as client:response = client.get("/library/embedding-settings")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_collections_page_route(self):"""Test /collections page route exists."""@@ -812,7 +812,7 @@ class TestRagPageRoutes:with app.test_client() as client:response = client.get("/library/collections")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codedef test_collection_details_page_route(self):"""Test /collections/<id> page route exists."""@@ -828,7 +828,7 @@ class TestRagPageRoutes:with app.test_client() as client:response = client.get("/library/collections/collection123")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 302, response.status_codedef test_collection_create_page_route(self):"""Test /collections/create page route exists."""@@ -844,7 +844,7 @@ class TestRagPageRoutes:with app.test_client() as client:response = client.get("/library/collections/create")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 302, response.status_codeclass TestRagBackgroundIndexRoutes:@@ -866,7 +866,7 @@ class TestRagBackgroundIndexRoutes:response = client.post("/library/api/collections/collection123/index/background")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 404, response.status_codedef test_get_index_status_route(self):"""Test /api/collections/<id>/index/status GET endpoint exists."""@@ -884,7 +884,7 @@ class TestRagBackgroundIndexRoutes:response = client.get("/library/api/collections/collection123/index/status")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codedef test_cancel_indexing_route(self):"""Test /api/collections/<id>/index/cancel POST endpoint exists."""@@ -902,7 +902,7 @@ class TestRagBackgroundIndexRoutes:response = client.post("/library/api/collections/collection123/index/cancel")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codeclass TestRagUploadRoutes:@@ -925,7 +925,7 @@ class TestRagUploadRoutes:response = client.post("/library/api/collections/collection123/upload")- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codeclass TestDocumentLoaders:@@ -1382,7 +1382,7 @@ class TestSupportedFormatsAPIEndpoint:"""Test that endpoint requires authentication."""response = client.get("/library/api/config/supported-formats")# Should redirect to login (302) or fail (500 if auth blueprint missing)- assert response.status_code in [302, 401, 500]+ assert response.status_code == 401, response.status_codedef test_endpoint_returns_json_when_authenticated(self, client, app):"""Test endpoint returns proper JSON when authenticated."""@@ -1507,7 +1507,7 @@ class TestConfigureRagEndpoint:},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_configure_rag_missing_provider(self):"""Test configure RAG with missing embedding_provider."""@@ -1531,7 +1531,7 @@ class TestConfigureRagEndpoint:},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_configure_rag_with_all_advanced_settings(self):"""Test configure RAG with all advanced settings."""@@ -1562,7 +1562,7 @@ class TestConfigureRagEndpoint:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestIndexDocumentEndpoint:@@ -1586,7 +1586,7 @@ class TestIndexDocumentEndpoint:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_index_document_with_force_reindex(self):"""Test index document with force_reindex flag."""@@ -1610,7 +1610,7 @@ class TestIndexDocumentEndpoint:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestRemoveDocumentEndpoint:@@ -1634,7 +1634,7 @@ class TestRemoveDocumentEndpoint:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codeclass TestIndexResearchEndpoint:@@ -1658,7 +1658,7 @@ class TestIndexResearchEndpoint:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codeclass TestIndexLocalEndpoint:@@ -1678,7 +1678,7 @@ class TestIndexLocalEndpoint:with app.test_client() as client:response = client.get("/library/api/rag/index-local")- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_index_local_path_traversal_attempt(self):"""Test index local with path traversal attempt."""@@ -1696,7 +1696,7 @@ class TestIndexLocalEndpoint:response = client.get("/library/api/rag/index-local?path=../../etc/passwd")- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_index_local_with_patterns(self):"""Test index local with custom patterns."""@@ -1714,7 +1714,7 @@ class TestIndexLocalEndpoint:response = client.get("/library/api/rag/index-local?path=/tmp&patterns=*.pdf,*.txt")- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestGetDocumentsEndpoint:@@ -1736,7 +1736,7 @@ class TestGetDocumentsEndpoint:response = client.get("/library/api/rag/documents?page=2&per_page=25")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_documents_filter_indexed(self):"""Test get documents with indexed filter."""@@ -1752,7 +1752,7 @@ class TestGetDocumentsEndpoint:with app.test_client() as client:response = client.get("/library/api/rag/documents?filter=indexed")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_documents_filter_unindexed(self):"""Test get documents with unindexed filter."""@@ -1768,7 +1768,7 @@ class TestGetDocumentsEndpoint:with app.test_client() as client:response = client.get("/library/api/rag/documents?filter=unindexed")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_documents_with_collection_id(self):"""Test get documents with collection_id."""@@ -1786,7 +1786,7 @@ class TestGetDocumentsEndpoint:response = client.get("/library/api/rag/documents?collection_id=coll123")- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestCollectionEndpoints:@@ -1810,7 +1810,7 @@ class TestCollectionEndpoints:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_create_collection_with_all_fields(self):"""Test create collection with all optional fields."""@@ -1834,7 +1834,7 @@ class TestCollectionEndpoints:},content_type="application/json",)- assert response.status_code in [200, 201, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_get_single_collection(self):"""Test get single collection."""@@ -1850,7 +1850,7 @@ class TestCollectionEndpoints:with app.test_client() as client:response = client.get("/library/api/collections/coll123")- assert response.status_code in [200, 302, 401, 403, 404, 405, 500]+ assert response.status_code == 405, response.status_codeclass TestCollectionDocumentEndpoints:@@ -1874,17 +1874,7 @@ class TestCollectionDocumentEndpoints:json={"document_id": "doc123"},content_type="application/json",)- assert response.status_code in [- 200,- 201,- 302,- 400,- 401,- 403,- 404,- 405,- 500,- ]+ assert response.status_code == 405, response.status_codedef test_remove_document_from_collection(self):"""Test removing document from collection."""@@ -1902,7 +1892,7 @@ class TestCollectionDocumentEndpoints:response = client.delete("/library/api/collections/coll123/documents/doc123")- assert response.status_code in [200, 302, 401, 403, 404, 405, 500]+ assert response.status_code == 404, response.status_codedef test_get_collection_documents(self):"""Test getting documents in a collection."""@@ -1918,7 +1908,7 @@ class TestCollectionDocumentEndpoints:with app.test_client() as client:response = client.get("/library/api/collections/coll123/documents")- assert response.status_code in [200, 302, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codeclass TestSearchEndpoint:@@ -1942,7 +1932,7 @@ class TestSearchEndpoint:json={},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403, 404]+ assert response.status_code == 404, response.status_codedef test_search_collection_with_limit(self):"""Test search with limit parameter."""@@ -1962,7 +1952,7 @@ class TestSearchEndpoint:json={"query": "test query", "limit": 5},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 404, response.status_codeclass TestFileUploadEndpoint:@@ -1988,7 +1978,7 @@ class TestFileUploadEndpoint:data=data,content_type="multipart/form-data",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codedef test_upload_txt_file(self):"""Test uploading a text file."""@@ -2010,7 +2000,7 @@ class TestFileUploadEndpoint:data=data,content_type="multipart/form-data",)- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 401, response.status_codeclass TestTestEmbeddingEndpoint:@@ -2034,7 +2024,7 @@ class TestTestEmbeddingEndpoint:json={"model": "all-MiniLM-L6-v2"},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_test_embedding_missing_model(self):"""Test embedding test without model."""@@ -2054,7 +2044,7 @@ class TestTestEmbeddingEndpoint:json={"provider": "sentence_transformers"},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codeclass TestRagEdgeCases:@@ -2083,7 +2073,7 @@ class TestRagEdgeCases:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_negative_chunk_size(self):"""Test configuration with negative chunk size."""@@ -2108,7 +2098,7 @@ class TestRagEdgeCases:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_overlap_larger_than_chunk(self):"""Test configuration where overlap > chunk size."""@@ -2133,7 +2123,7 @@ class TestRagEdgeCases:},content_type="application/json",)- assert response.status_code in [200, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_sql_injection_in_collection_id(self):"""Test SQL injection attempt in collection ID."""@@ -2151,16 +2141,7 @@ class TestRagEdgeCases:response = client.get("/library/api/collections/'; DROP TABLE collections; --")- assert response.status_code in [- 200,- 302,- 400,- 401,- 403,- 404,- 405,- 500,- ]+ assert response.status_code == 405, response.status_codedef test_special_chars_in_collection_name(self):"""Test creating collection with special characters."""@@ -2180,7 +2161,7 @@ class TestRagEdgeCases:json={"name": "<script>alert('xss')</script>"},content_type="application/json",)- assert response.status_code in [200, 201, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_unicode_in_collection_name(self):"""Test creating collection with unicode characters."""@@ -2200,7 +2181,7 @@ class TestRagEdgeCases:json={"name": "测试集合 コレクション مجموعة"},content_type="application/json",)- assert response.status_code in [200, 201, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codedef test_empty_collection_name(self):"""Test creating collection with empty name."""@@ -2220,7 +2201,7 @@ class TestRagEdgeCases:json={"name": ""},content_type="application/json",)- assert response.status_code in [302, 400, 401, 403]+ assert response.status_code == 401, response.status_codedef test_very_long_collection_name(self):"""Test creating collection with very long name."""@@ -2240,7 +2221,7 @@ class TestRagEdgeCases:json={"name": "a" * 10000},content_type="application/json",)- assert response.status_code in [200, 201, 302, 400, 401, 403, 500]+ assert response.status_code == 401, response.status_codeclass TestCollectionNormalizeVectors:@@ -2331,7 +2312,7 @@ class TestIndexAllStreamingResponse:with app.test_client() as client:response = client.get("/library/api/rag/index-all")# Should return 200 with text/event-stream or require auth- assert response.status_code in [200, 302, 401, 403, 500]+ assert response.status_code == 401, response.status_codeif response.status_code == 200:assert "text/event-stream" in response.content_type@@ -2353,7 +2334,7 @@ class TestAutoIndexTrigger:with app.test_client() as client:response = client.post("/library/api/rag/trigger-auto-index")- assert response.status_code in [200, 302, 400, 401, 403, 404, 500]+ assert response.status_code == 404, response.status_codeclass TestSettingsManagerImportCompatibility: