(self)
| 597 | class TestS3FilesStore: |
| 598 | @inline_callbacks_test |
| 599 | def test_persist(self): |
| 600 | bucket = "mybucket" |
| 601 | key = "export.csv" |
| 602 | uri = f"s3://{bucket}/{key}" |
| 603 | buffer = mock.MagicMock() |
| 604 | meta = {"foo": "bar"} |
| 605 | path = "" |
| 606 | content_type = "image/png" |
| 607 | |
| 608 | store = S3FilesStore(uri) |
| 609 | from botocore.stub import Stubber # noqa: PLC0415 |
| 610 | |
| 611 | with Stubber(store.s3_client) as stub: |
| 612 | stub.add_response( |
| 613 | "put_object", |
| 614 | expected_params={ |
| 615 | "ACL": S3FilesStore.POLICY, |
| 616 | "Body": buffer, |
| 617 | "Bucket": bucket, |
| 618 | "CacheControl": S3FilesStore.HEADERS["Cache-Control"], |
| 619 | "ContentType": content_type, |
| 620 | "Key": key, |
| 621 | "Metadata": meta, |
| 622 | }, |
| 623 | service_response={}, |
| 624 | ) |
| 625 | |
| 626 | yield store.persist_file( |
| 627 | path, |
| 628 | buffer, |
| 629 | info=None, |
| 630 | meta=meta, |
| 631 | headers={"Content-Type": content_type}, |
| 632 | ) |
| 633 | |
| 634 | stub.assert_no_pending_responses() |
| 635 | # The call to read does not happen with Stubber |
| 636 | assert buffer.method_calls == [mock.call.seek(0)] |
| 637 | |
| 638 | @inline_callbacks_test |
| 639 | def test_stat(self): |
nothing calls this directly
no test coverage detected