From 73b21e8d6456dccf46070641182a5b97ef27ca3f Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 8 Jul 2026 09:32:37 +0000 Subject: [PATCH] =?UTF-8?q?Treat=20a=20selection=20with=20no=20documents?= =?UTF-8?q?=20as=20a=20recorded=20failure=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- ...est_bulk_document_download_orchestrator.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/orchestration/test_bulk_document_download_orchestrator.py b/tests/orchestration/test_bulk_document_download_orchestrator.py index b1b48830a..02400e16f 100644 --- a/tests/orchestration/test_bulk_document_download_orchestrator.py +++ b/tests/orchestration/test_bulk_document_download_orchestrator.py @@ -11,6 +11,7 @@ from datetime import datetime, timezone import pytest from moto import mock_aws +from domain.tasks.subtasks import SubTaskFailure from infrastructure.postgres.uploaded_file_table import FileTypeEnum, UploadedFile from infrastructure.s3.s3_client import S3Client from orchestration.bulk_document_download_orchestrator import ( @@ -111,3 +112,28 @@ def test_builds_uploads_and_emails_a_download_package(packages: S3Client) -> Non to, _subject, body = email.sent[0] assert to == "user@example.com" assert result.presigned_url in body + + +def test_a_selection_with_no_documents_is_a_recorded_failure( + packages: S3Client, +) -> None: + # Arrange — the selection resolves to no packageable documents. + email = _RecordingEmail() + orchestrator = BulkDocumentDownloadOrchestrator( + uploaded_files=_FakeUploadedFiles([]), + addresses=_FakeAddresses({}), + documents=_FakeDocuments({}), + packages=packages, + email=email, + url_ttl_seconds=3600, + ) + + # Act / Assert — a recorded SubTask failure, and nobody is emailed an empty + # package. + with pytest.raises(SubTaskFailure): + orchestrator.run( + landlord_property_ids=["LP1"], + recipient_email="user@example.com", + package_name="empty", + ) + assert email.sent == []