From 3846c4699018f997b2f18e4af284b118771ca6c4 Mon Sep 17 00:00:00 2001 From: Konstantinos Koukopoulos Date: Fri, 15 Nov 2013 11:53:39 +0200 Subject: [PATCH] replace literal ints with constants --- moto/s3/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/moto/s3/models.py b/moto/s3/models.py index 7447d0cd9..e59558864 100644 --- a/moto/s3/models.py +++ b/moto/s3/models.py @@ -7,6 +7,9 @@ from moto.core import BaseBackend from moto.core.utils import iso_8601_datetime, rfc_1123_datetime from .utils import clean_key_name +UPLOAD_ID_BYTES=43 +UPLOAD_PART_MIN_SIZE=5242880 + class FakeKey(object): def __init__(self, name, value): @@ -58,14 +61,14 @@ class FakeMultipart(object): def __init__(self, key_name): self.key_name = key_name self.parts = {} - self.id = base64.b64encode(os.urandom(43)).replace('=', '').replace('+', '') + self.id = base64.b64encode(os.urandom(UPLOAD_ID_BYTES)).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: + if part.name != last_part_name and len(part.value) < UPLOAD_PART_MIN_SIZE: return total.extend(part.value)