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: replace `... or True` weak assertions with real outcomes (#4406)

LearningCircuitf7dac0ed2cd8
diff --git a/tests/database/test_sqlcipher_integration.py b/tests/database/test_sqlcipher_integration.py
index f27690c483..3a749e3b87 100644
--- a/tests/database/test_sqlcipher_integration.py
+++ b/tests/database/test_sqlcipher_integration.py
@@ -3711,11 +3711,10 @@ class TestSQLCipherIntegration:
finally:
conn.close()
- # Tampering should be detected (either via integrity check or exception)
- # Note: Depending on which bytes were tampered, detection may vary
- assert tampering_detected or True, (
- "Last page tampering should be detectable"
- ) # Soft assertion - tampering detection varies
+ # Tampering should be detected (either via integrity check or exception).
+ # The 64-byte XOR-0xFF flip above invalidates the per-page HMAC, which
+ # cipher_integrity_check / integrity_check are required to report.
+ assert tampering_detected, "Last page tampering should be detectable"
def test_integrity_check_with_plaintext_header(self, tmp_path):
"""Test cipher_integrity_check works with plaintext header enabled.
diff --git a/tests/metrics/test_token_counter_extended.py b/tests/metrics/test_token_counter_extended.py
index fb61ffa64b..331c2149cc 100644
--- a/tests/metrics/test_token_counter_extended.py
+++ b/tests/metrics/test_token_counter_extended.py
@@ -412,23 +412,6 @@ class TestCallStackTracking:
frames = callback.call_stack.split(" -> ")
assert len(frames) <= 5
- def test_call_stack_reset(self):
- """Test call stack is reset between calls"""
- callback = TokenCountingCallback()
-
- # First call
- callback.on_llm_start({"_type": "ChatOpenAI"}, ["test1"])
- first_stack = callback.call_stack
-
- # Second call
- callback.on_llm_start({"_type": "ChatOpenAI"}, ["test2"])
- second_stack = callback.call_stack
-
- # Stack should be recaptured
- assert (
- first_stack == second_stack or True
- ) # May be same in test context
-
def test_concurrent_call_tracking(self):
"""Test concurrent calls are tracked separately"""
callback1 = TokenCountingCallback(research_id="test-1")
diff --git a/tests/news/test_flask_api_routes.py b/tests/news/test_flask_api_routes.py
index af6b53651f..d6d369a949 100644
--- a/tests/news/test_flask_api_routes.py
+++ b/tests/news/test_flask_api_routes.py
@@ -244,23 +244,37 @@ class TestErrorHandlers:
"""Tests for error handlers."""
def test_bad_request_handler(self, app, client):
- """Test 400 error handler."""
- # The error handler should be registered
- from local_deep_research.news.flask_api import news_api_bp
+ """The 400 handler returns the documented JSON envelope, not Flask's HTML."""
+ from werkzeug.exceptions import BadRequest
- assert news_api_bp.error_handler_spec.get(400) or True
+ from local_deep_research.news.flask_api import bad_request
+
+ with app.app_context():
+ response, status = bad_request(BadRequest())
+ assert status == 400
+ assert response.get_json() == {"error": "Bad request"}
def test_not_found_handler(self, app, client):
- """Test 404 error handler."""
- from local_deep_research.news.flask_api import news_api_bp
+ """The 404 handler returns the documented JSON envelope."""
+ from werkzeug.exceptions import NotFound
+
+ from local_deep_research.news.flask_api import not_found
- assert news_api_bp.error_handler_spec.get(404) or True
+ with app.app_context():
+ response, status = not_found(NotFound())
+ assert status == 404
+ assert response.get_json() == {"error": "Resource not found"}
def test_internal_error_handler(self, app, client):
- """Test 500 error handler."""
- from local_deep_research.news.flask_api import news_api_bp
+ """The 500 handler returns the documented JSON envelope."""
+ from werkzeug.exceptions import InternalServerError
+
+ from local_deep_research.news.flask_api import internal_error
- assert news_api_bp.error_handler_spec.get(500) or True
+ with app.app_context():
+ response, status = internal_error(InternalServerError())
+ assert status == 500
+ assert response.get_json() == {"error": "Internal server error"}
# ============= Run Subscription Now Tests =============
diff --git a/tests/research_library/services/test_download_service.py b/tests/research_library/services/test_download_service.py
index 053516b30d..8fb869deaf 100644
--- a/tests/research_library/services/test_download_service.py
+++ b/tests/research_library/services/test_download_service.py
@@ -1348,9 +1348,7 @@ class TestDownloadAsText:
service = DownloadService(username="test_user")
# Verify service can record failed extractions
- assert (
- hasattr(service, "_record_failed_text_extraction") or True
- ) # Method may or may not exist
+ assert hasattr(service, "_record_failed_text_extraction")
class TestSaveTextWithDb:
diff --git a/tests/research_library/services/test_library_rag_service.py b/tests/research_library/services/test_library_rag_service.py
index 216d695f3f..282bfbe81f 100644
--- a/tests/research_library/services/test_library_rag_service.py
+++ b/tests/research_library/services/test_library_rag_service.py
@@ -834,9 +834,10 @@ class TestLoadOrCreateFaissIndexEdgeCases:
embedding_manager=mock_embedding_manager,
)
- # Should attempt to handle corrupted index
+ # Corrupted index path: SUT quarantines the bad file and falls
+ # through to building a fresh FAISS index — must not return None.
result = service.load_or_create_faiss_index("collection-123")
- assert result is not None or True # May return None or new index
+ assert result is not None
def test_load_index_with_different_embedding_dimension(self, mocker):
"""Handles dimension mismatch between index and current embeddings."""
@@ -886,10 +887,10 @@ class TestLoadOrCreateFaissIndexEdgeCases:
embedding_manager=mock_embedding_manager,
)
- # Service should handle dimension mismatch
+ # Dimension mismatch: SUT deletes the stale index, updates the
+ # RAGIndex row, and rebuilds — must return a fresh FAISS index.
result = service.load_or_create_faiss_index("collection-123")
- # Either returns new index or raises appropriate error
- assert result is not None or True
+ assert result is not None
def test_create_index_with_normalize_vectors(self, mocker):
"""Creates index with vector normalization enabled."""