Add assertion for Copied Object
Change-Id: I054522f977e778378ac5331154ad22e08d3c2d59
This commit is contained in:
@@ -20,6 +20,7 @@ from time import mktime
|
|||||||
|
|
||||||
from multifile import MultiFile
|
from multifile import MultiFile
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
from hashlib import md5
|
||||||
|
|
||||||
from swift3.test.functional.s3_test_client import Connection
|
from swift3.test.functional.s3_test_client import Connection
|
||||||
from swift3.test.functional.utils import get_error_code,\
|
from swift3.test.functional.utils import get_error_code,\
|
||||||
@@ -246,7 +247,15 @@ class TestSwift3Object(Swift3FunctionalTestCase):
|
|||||||
|
|
||||||
def test_put_object_copy_source(self):
|
def test_put_object_copy_source(self):
|
||||||
obj = 'object'
|
obj = 'object'
|
||||||
self.conn.make_request('PUT', self.bucket, obj)
|
content = 'abcdefghij'
|
||||||
|
content_md5 = md5(content).hexdigest()
|
||||||
|
self.conn.make_request('PUT', self.bucket, obj, body=content)
|
||||||
|
|
||||||
|
def assertCopiedObject(bucket, obj):
|
||||||
|
status, headers, _ = self.conn.make_request('HEAD', bucket, obj)
|
||||||
|
self.assertEquals(status, 200) # sanity
|
||||||
|
self.assertEquals(content_md5, headers['etag'].strip('"'))
|
||||||
|
|
||||||
dst_bucket = 'dst_bucket'
|
dst_bucket = 'dst_bucket'
|
||||||
dst_obj = 'dst_object'
|
dst_obj = 'dst_object'
|
||||||
self.conn.make_request('PUT', dst_bucket)
|
self.conn.make_request('PUT', dst_bucket)
|
||||||
@@ -256,12 +265,14 @@ class TestSwift3Object(Swift3FunctionalTestCase):
|
|||||||
status, headers, body = \
|
status, headers, body = \
|
||||||
self.conn.make_request('PUT', dst_bucket, dst_obj, headers)
|
self.conn.make_request('PUT', dst_bucket, dst_obj, headers)
|
||||||
self.assertEquals(status, 200)
|
self.assertEquals(status, 200)
|
||||||
|
assertCopiedObject(dst_bucket, dst_obj)
|
||||||
|
|
||||||
# /src/src -> /src/dst
|
# /src/src -> /src/dst
|
||||||
headers = {'X-Amz-Copy-Source': '/%s/%s' % (self.bucket, obj)}
|
headers = {'X-Amz-Copy-Source': '/%s/%s' % (self.bucket, obj)}
|
||||||
status, headers, body = \
|
status, headers, body = \
|
||||||
self.conn.make_request('PUT', self.bucket, dst_obj, headers)
|
self.conn.make_request('PUT', self.bucket, dst_obj, headers)
|
||||||
self.assertEquals(status, 200)
|
self.assertEquals(status, 200)
|
||||||
|
assertCopiedObject(self.bucket, dst_obj)
|
||||||
|
|
||||||
# /src/src -> /src/src
|
# /src/src -> /src/src
|
||||||
# need changes to copy itself (e.g. metadata)
|
# need changes to copy itself (e.g. metadata)
|
||||||
@@ -271,6 +282,7 @@ class TestSwift3Object(Swift3FunctionalTestCase):
|
|||||||
status, headers, body = \
|
status, headers, body = \
|
||||||
self.conn.make_request('PUT', self.bucket, obj, headers)
|
self.conn.make_request('PUT', self.bucket, obj, headers)
|
||||||
self.assertEquals(status, 200)
|
self.assertEquals(status, 200)
|
||||||
|
assertCopiedObject(self.bucket, obj)
|
||||||
|
|
||||||
def test_put_object_copy_metadata_directive(self):
|
def test_put_object_copy_metadata_directive(self):
|
||||||
obj = 'object'
|
obj = 'object'
|
||||||
|
|||||||
Reference in New Issue
Block a user