From 34c48d4adc591c88b5659029d78fa3399b25ce47 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 8 Jul 2026 09:05:44 +0000 Subject: [PATCH] =?UTF-8?q?Skip=20and=20report=20a=20document=20with=20no?= =?UTF-8?q?=20Document=20Type=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 --- .../test_package_plan.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/domain/bulk_document_download/test_package_plan.py b/tests/domain/bulk_document_download/test_package_plan.py index 2271aefd0..a81e84171 100644 --- a/tests/domain/bulk_document_download/test_package_plan.py +++ b/tests/domain/bulk_document_download/test_package_plan.py @@ -3,6 +3,7 @@ documents: one folder per property, latest file of each Document Type, null-Document-Type rows skipped and reported.""" from datetime import datetime, timezone +from typing import Optional from domain.bulk_document_download.package_plan import ( ResolvedDocument, @@ -14,7 +15,7 @@ def _doc( *, landlord_property_id: str = "LP1", address: str = "12 Oak Street", - document_type: str = "site_note", + document_type: Optional[str] = "site_note", s3_key: str = "a.pdf", uploaded_at: datetime = datetime(2026, 1, 1, tzinfo=timezone.utc), ) -> ResolvedDocument: @@ -46,3 +47,20 @@ def test_keeps_only_the_latest_file_of_a_document_type_in_the_property_folder() entry = plan.entries[0] assert entry.s3_key == "new.pdf" assert entry.zip_path.startswith("12 Oak Street (LP1)/") + + +def test_skips_and_reports_a_document_with_no_document_type() -> None: + # Arrange — one packable file and one row whose Document Type is null + # (file_type is nullable on uploaded_files). + packable = _doc(document_type="site_note", s3_key="note.pdf") + untyped = _doc(document_type=None, s3_key="mystery.bin") + + # Act + plan = plan_download_package([packable, untyped]) + + # Assert — the untyped row is left out of the archive and reported instead. + assert [e.s3_key for e in plan.entries] == ["note.pdf"] + assert len(plan.skipped) == 1 + skipped = plan.skipped[0] + assert skipped.s3_key == "mystery.bin" + assert skipped.landlord_property_id == "LP1"