Add assertion for Copied Object

Change-Id: I054522f977e778378ac5331154ad22e08d3c2d59
This commit is contained in:
Kota Tsuyuzaki
2015-03-27 08:35:52 -07:00
parent ff4498de04
commit 01ecf843a8

View File

@@ -20,6 +20,7 @@ from time import mktime
from multifile import MultiFile
from cStringIO import StringIO
from hashlib import md5
from swift3.test.functional.s3_test_client import Connection
from swift3.test.functional.utils import get_error_code,\
@@ -246,7 +247,15 @@ class TestSwift3Object(Swift3FunctionalTestCase):
def test_put_object_copy_source(self):
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_obj = 'dst_object'
self.conn.make_request('PUT', dst_bucket)
@@ -256,12 +265,14 @@ class TestSwift3Object(Swift3FunctionalTestCase):
status, headers, body = \
self.conn.make_request('PUT', dst_bucket, dst_obj, headers)
self.assertEquals(status, 200)
assertCopiedObject(dst_bucket, dst_obj)
# /src/src -> /src/dst
headers = {'X-Amz-Copy-Source': '/%s/%s' % (self.bucket, obj)}
status, headers, body = \
self.conn.make_request('PUT', self.bucket, dst_obj, headers)
self.assertEquals(status, 200)
assertCopiedObject(self.bucket, dst_obj)
# /src/src -> /src/src
# need changes to copy itself (e.g. metadata)
@@ -271,6 +282,7 @@ class TestSwift3Object(Swift3FunctionalTestCase):
status, headers, body = \
self.conn.make_request('PUT', self.bucket, obj, headers)
self.assertEquals(status, 200)
assertCopiedObject(self.bucket, obj)
def test_put_object_copy_metadata_directive(self):
obj = 'object'