From 4ef484d9085454399f272c5d9bad740deecd8f03 Mon Sep 17 00:00:00 2001 From: Konstantinos Koukopoulos Date: Tue, 10 Feb 2015 13:05:31 +0200 Subject: [PATCH] add test for uploading parts out of order in S3 multipart upload --- tests/test_s3/test_s3.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py index 1643eaaff..c77918c07 100644 --- a/tests/test_s3/test_s3.py +++ b/tests/test_s3/test_s3.py @@ -87,6 +87,22 @@ def test_multipart_upload(): bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + part2) +@mock_s3 +def test_multipart_upload_out_of_order(): + conn = boto.connect_s3('the_key', 'the_secret') + bucket = conn.create_bucket("foobar") + + multipart = bucket.initiate_multipart_upload("the-key") + # last part, can be less than 5 MB + part2 = b'1' + multipart.upload_part_from_file(BytesIO(part2), 4) + part1 = b'0' * 5242880 + multipart.upload_part_from_file(BytesIO(part1), 2) + multipart.complete_upload() + # we should get both parts as the key contents + bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + part2) + + @mock_s3 def test_multipart_upload_with_headers(): conn = boto.connect_s3('the_key', 'the_secret')