From 01ecf843a83f2cb182f8514e47b344b4e81a342f Mon Sep 17 00:00:00 2001 From: Kota Tsuyuzaki Date: Fri, 27 Mar 2015 08:35:52 -0700 Subject: [PATCH] Add assertion for Copied Object Change-Id: I054522f977e778378ac5331154ad22e08d3c2d59 --- swift3/test/functional/test_object.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/swift3/test/functional/test_object.py b/swift3/test/functional/test_object.py index 60736c7e..a45831b8 100644 --- a/swift3/test/functional/test_object.py +++ b/swift3/test/functional/test_object.py @@ -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'