"""The multi-bucket document reader (ADR-0060) — reads object bytes from whichever source bucket an uploaded file lives in.""" from collections.abc import Iterator import pytest from moto import mock_aws from infrastructure.s3.s3_document_bytes_reader import S3DocumentBytesReader from tests.infrastructure import make_boto_client @pytest.fixture def reader() -> Iterator[S3DocumentBytesReader]: with mock_aws(): boto_client = make_boto_client("s3") boto_client.create_bucket(Bucket="src-a") boto_client.create_bucket(Bucket="src-b") boto_client.put_object(Bucket="src-a", Key="surveys/one.pdf", Body=b"AAA") boto_client.put_object(Bucket="src-b", Key="photos/two.zip", Body=b"BBB") yield S3DocumentBytesReader(boto_client) def test_reads_bytes_from_the_named_source_bucket( reader: S3DocumentBytesReader, ) -> None: # act / assert — each object is read from its own bucket. assert reader.read("src-a", "surveys/one.pdf") == b"AAA" assert reader.read("src-b", "photos/two.zip") == b"BBB"