From 67bb05c87e3f456e91be980c69e49828d08ba1a1 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 24 Nov 2014 10:47:16 -0800 Subject: [PATCH] s3test: test copy version Signed-off-by: Yehuda Sadeh --- s3tests/functional/test_s3.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index f78c4bf..b40b182 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -5534,3 +5534,33 @@ def test_versioning_obj_create_overwrite_multipart(): eq(len(k), 0) eq(len(k), len(c)) + + +def test_versioning_copy_obj_version(): + bucket = get_new_bucket() + + check_configure_versioning_retry(bucket, True, "Enabled") + + num_versions = 3 + objname = 'testobj' + + (k, c) = create_multiple_versions(bucket, objname, num_versions) + + # copy into the same bucket + for i in xrange(num_versions): + new_key_name = 'key_{i}'.format(i=i) + new_key = bucket.copy_key(new_key_name, bucket.name, k[i].name, src_version_id=k[i].version_id) + eq(new_key.get_contents_as_string(), c[i]) + + another_bucket = get_new_bucket() + + # copy into a different bucket + for i in xrange(num_versions): + new_key_name = 'key_{i}'.format(i=i) + new_key = another_bucket.copy_key(new_key_name, bucket.name, k[i].name, src_version_id=k[i].version_id) + eq(new_key.get_contents_as_string(), c[i]) + + # test copy of head object + new_key = another_bucket.copy_key('new_key', bucket.name, objname) + eq(new_key.get_contents_as_string(), c[num_versions - 1]) +