From 77e7b0fda96040adf01f9132b41d7bc0754eace5 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 8 Jul 2026 09:33:58 +0000 Subject: [PATCH] =?UTF-8?q?Package=20the=20good=20documents=20and=20report?= =?UTF-8?q?=20the=20skipped=20ones=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pins the best-effort contract (ADR-0060) delivered with the tracer — no red phase; discriminating: a strict impl would fail the run or omit the report. Co-Authored-By: Claude Fable 5 --- ...est_bulk_document_download_orchestrator.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/orchestration/test_bulk_document_download_orchestrator.py b/tests/orchestration/test_bulk_document_download_orchestrator.py index 02400e16f..40c483d80 100644 --- a/tests/orchestration/test_bulk_document_download_orchestrator.py +++ b/tests/orchestration/test_bulk_document_download_orchestrator.py @@ -137,3 +137,42 @@ def test_a_selection_with_no_documents_is_a_recorded_failure( package_name="empty", ) assert email.sent == [] + + +def test_packages_the_good_documents_and_reports_the_skipped_ones( + packages: S3Client, +) -> None: + # Arrange — one packable site note and one row with no Document Type. + good = _uploaded_file("LP1", "src-bucket", "surveys/a.pdf") + untyped = UploadedFile( + s3_file_bucket="src-bucket", + s3_file_key="mystery.bin", + s3_upload_timestamp=datetime(2026, 1, 1, tzinfo=timezone.utc), + landlord_property_id="LP1", + file_type=None, + ) + email = _RecordingEmail() + orchestrator = BulkDocumentDownloadOrchestrator( + uploaded_files=_FakeUploadedFiles([good, untyped]), + addresses=_FakeAddresses({"LP1": "12 Oak Street"}), + documents=_FakeDocuments({("src-bucket", "surveys/a.pdf"): b"PDF-BYTES"}), + packages=packages, + email=email, + url_ttl_seconds=3600, + ) + + # Act + result = orchestrator.run( + landlord_property_ids=["LP1"], + recipient_email="user@example.com", + package_name="mixed", + ) + + # Assert — the good file is packaged and delivered; the untyped one is + # reported, not fatal. + assert result.included == 1 + assert [s.s3_key for s in result.skipped] == ["mystery.bin"] + assert len(email.sent) == 1 + archive = packages.get_object(result.package_s3_key) + with zipfile.ZipFile(io.BytesIO(archive)) as zf: + assert zf.namelist() == ["12 Oak Street (LP1)/site_note.pdf"]