Merge "Add S3Timestamp.now() method for the current time"
This commit is contained in:
@@ -45,7 +45,6 @@ upload information:
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
from swift.common.utils import json
|
||||
from swift.common.db import utf8encode
|
||||
@@ -121,7 +120,7 @@ class PartController(Controller):
|
||||
req.object_name = '%s/%s/%d' % (req.object_name, upload_id,
|
||||
part_number)
|
||||
|
||||
req_timestamp = S3Timestamp(time.time())
|
||||
req_timestamp = S3Timestamp.now()
|
||||
req.headers['X-Timestamp'] = req_timestamp.internal
|
||||
req.check_copy_source(self.app)
|
||||
resp = req.get_response(self.app)
|
||||
|
@@ -14,7 +14,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
import time
|
||||
|
||||
from swift.common.http import HTTP_OK, HTTP_PARTIAL_CONTENT, HTTP_NO_CONTENT
|
||||
from swift.common.swob import Range, content_range_header_value
|
||||
@@ -98,7 +97,7 @@ class ObjectController(Controller):
|
||||
Handle PUT Object and PUT Object (Copy) request
|
||||
"""
|
||||
# set X-Timestamp by swift3 to use at copy resp body
|
||||
req_timestamp = S3Timestamp(time.time())
|
||||
req_timestamp = S3Timestamp.now()
|
||||
req.headers['X-Timestamp'] = req_timestamp.internal
|
||||
req.check_copy_source(self.app)
|
||||
resp = req.get_response(self.app)
|
||||
|
@@ -1116,8 +1116,7 @@ class TestSwift3MultiUpload(Swift3TestCase):
|
||||
'/bucket/object?partNumber=1&uploadId=X',
|
||||
environ={'REQUEST_METHOD': 'PUT'},
|
||||
headers=put_headers)
|
||||
with patch('swift3.controllers.multi_upload.time.time') as mock_time:
|
||||
mock_time.return_value = 1396353600.592270
|
||||
with patch('swift3.utils.time.time', return_value=1396353600.592270):
|
||||
return self.call_swift3(req)
|
||||
|
||||
@s3acl
|
||||
|
@@ -469,8 +469,7 @@ class TestSwift3Obj(Swift3TestCase):
|
||||
|
||||
req.date = datetime.now()
|
||||
req.content_type = 'text/plain'
|
||||
with patch('swift3.controllers.obj.time.time') as mock_time:
|
||||
mock_time.return_value = 1396353600.000000
|
||||
with patch('swift3.utils.time.time', return_value=1396353600.000000):
|
||||
return self.call_swift3(req)
|
||||
|
||||
@s3acl
|
||||
|
@@ -16,6 +16,7 @@
|
||||
import re
|
||||
import uuid
|
||||
import base64
|
||||
import time
|
||||
|
||||
|
||||
from swift.common.utils import get_logger
|
||||
@@ -141,3 +142,7 @@ class S3Timestamp(utils.Timestamp):
|
||||
@property
|
||||
def s3xmlformat(self):
|
||||
return self.isoformat[:-7] + '.000Z'
|
||||
|
||||
@classmethod
|
||||
def now(cls):
|
||||
return cls(time.time())
|
||||
|
Reference in New Issue
Block a user