| 24 | |
| 25 | |
| 26 | class S3FileExistsTests(unittest.TestCase): |
| 27 | def test_file_exists_falls_back_to_list_objects(self): |
| 28 | client = FakeS3Client({"Contents": [{"Key": "share/data/file.txt"}]}) |
| 29 | storage = S3FileStorage.__new__(S3FileStorage) |
| 30 | storage.bucket_name = "bucket" |
| 31 | storage._client = lambda: client |
| 32 | |
| 33 | exists = asyncio.run(storage.file_exists("share/data/file.txt")) |
| 34 | |
| 35 | self.assertTrue(exists) |
| 36 | self.assertEqual(client.head_calls, 3) |
| 37 | |
| 38 | def test_file_exists_returns_false_when_missing(self): |
| 39 | client = FakeS3Client({"Contents": [{"Key": "share/data/other.txt"}]}) |
| 40 | storage = S3FileStorage.__new__(S3FileStorage) |
| 41 | storage.bucket_name = "bucket" |
| 42 | storage._client = lambda: client |
| 43 | |
| 44 | exists = asyncio.run(storage.file_exists("share/data/file.txt")) |
| 45 | |
| 46 | self.assertFalse(exists) |
nothing calls this directly
no outgoing calls
no test coverage detected