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(library): assert download cascade-delete in sync upload regression (#3952)

LearningCircuit1eb6cca2a696
diff --git a/tests/research_library/services/test_library_service.py b/tests/research_library/services/test_library_service.py
index f214ef8619..9078062fdf 100644
--- a/tests/research_library/services/test_library_service.py
+++ b/tests/research_library/services/test_library_service.py
@@ -946,8 +946,9 @@ class TestSyncLibraryUploadsIntegration:
title="User Upload",
status=DocumentStatus.COMPLETED,
)
+ download_id = str(uuid.uuid4())
download = Document(
- id=str(uuid.uuid4()),
+ id=download_id,
source_type_id=mock_source_type.id,
document_hash=hashlib.sha256(b"download").hexdigest(),
original_url="https://example.com/paper.pdf",
@@ -981,6 +982,14 @@ class TestSyncLibraryUploadsIntegration:
assert library_session.query(Document).get(upload_id) is not None
assert stats["total_documents"] == 1 # only the download is counted
+ # The download has no DownloadTracker, so it must still travel through
+ # the destructive `else` branch and be cascade-deleted. Asserting this
+ # explicitly proves the deletion path stays functional for legitimate
+ # downloads — without it, a regression that broke the else branch
+ # would still pass the upload-survival check above.
+ assert library_session.query(Document).get(download_id) is None
+ assert stats["files_missing"] == 1
+
class TestMarkForRedownloadUploadsIntegration:
"""Regression for #3869: mark_for_redownload must not crash on uploads."""