Skip to content

Commit ca31109

Browse files
committed
[S3] Add chunk_size test for download_object_range_as_stream
1 parent 556fd0c commit ca31109

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

libcloud/test/storage/test_s3.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,35 @@ def test_download_object_as_stream_uses_chunk_size(self):
885885

886886
mock_response.iter_content.assert_called_once_with(requested_chunk_size)
887887

888+
def test_download_object_range_as_stream_uses_chunk_size(self):
889+
# Same regression as above, but for the ranged variant which goes
890+
# through the same _get_object() code path.
891+
container = Container(name="foo_bar_container", extra={}, driver=self.driver)
892+
obj = Object(
893+
name="foo_bar_object",
894+
size=1000,
895+
hash=None,
896+
extra={},
897+
container=container,
898+
meta_data=None,
899+
driver=self.driver_type,
900+
)
901+
902+
requested_chunk_size = CHUNK_SIZE * 2
903+
mock_response = Mock(name="mock response")
904+
mock_response.iter_content.return_value = iter([b"a"])
905+
906+
with mock.patch.object(self.driver.connection, "request", return_value=mock_response):
907+
with mock.patch.object(self.driver, "_get_object", side_effect=lambda **kw: kw):
908+
self.driver.download_object_range_as_stream(
909+
obj=obj,
910+
start_bytes=0,
911+
end_bytes=100,
912+
chunk_size=requested_chunk_size,
913+
)
914+
915+
mock_response.iter_content.assert_called_once_with(requested_chunk_size)
916+
888917
def test_upload_object_invalid_ex_storage_class(self):
889918
# Invalid hash is detected on the amazon side and BAD_REQUEST is
890919
# returned

0 commit comments

Comments
 (0)