Treat a selection with no documents as a recorded failure 🟥

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-08 09:32:37 +00:00
parent e7181b7d1f
commit 73b21e8d64

View file

@ -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 == []