mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Package the good documents and report the skipped ones 🟩
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 <noreply@anthropic.com>
This commit is contained in:
parent
59ef8a12ab
commit
77e7b0fda9
1 changed files with 39 additions and 0 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue