From b64dbcaa12aa284d7a0ae39d9337747522641ee0 Mon Sep 17 00:00:00 2001 From: Mike Attili Date: Thu, 7 Nov 2013 17:07:56 -0500 Subject: [PATCH 1/2] Remove ()'s on complete_upload since should.throw requires a 'callable'. --- tests/test_s3/test_s3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_s3/test_s3.py b/tests/test_s3/test_s3.py index f4a5ad18..8cbd489d 100644 --- a/tests/test_s3/test_s3.py +++ b/tests/test_s3/test_s3.py @@ -47,7 +47,7 @@ def test_multipart_upload(): multipart.upload_part_from_file(BytesIO('hello'), 1) multipart.upload_part_from_file(BytesIO('world'), 2) # Multipart with total size under 5MB is refused - multipart.complete_upload().should.throw(S3ResponseError) + multipart.complete_upload.should.throw(S3ResponseError) multipart = bucket.initiate_multipart_upload("the-key") part1 = '0' * 5242880 From d9862aaa65aac24d3f66c4e41aebbb55b50bd853 Mon Sep 17 00:00:00 2001 From: Mike Attili Date: Thu, 7 Nov 2013 17:09:53 -0500 Subject: [PATCH 2/2] Correct size check on multipart uploads. All parts except last must be > 5MB --- moto/s3/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/moto/s3/models.py b/moto/s3/models.py index a97e2862..9ab0a5b8 100644 --- a/moto/s3/models.py +++ b/moto/s3/models.py @@ -60,16 +60,15 @@ class FakeMultipart(object): self.parts = {} self.id = base64.b64encode(os.urandom(43)).replace('=', '').replace('+', '') - def complete(self): total = bytearray() + last_part_name = len(self.list_parts()) for part in self.list_parts(): + if part.name != last_part_name and len(part.value) < 5242880: + return total.extend(part.value) - if len(total) < 5242880: - return - return total def set_part(self, part_id, value):