From 304e3422e2706729c40856ba32b930ff7fcd6c33 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 14 Jun 2012 17:07:46 -0700 Subject: [PATCH] test two cases in copying object to itself - should fail when not trying to change metadata - should succeed when changing metadata; also verify metadata Signed-off-by: Yehuda Sadeh --- s3tests/functional/test_s3.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 0fbd725..3806d69 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -2745,6 +2745,35 @@ def test_object_copy_same_bucket(): key2 = bucket.get_key('bar321foo') eq(key2.get_contents_as_string(), 'foo') +@attr(resource='object') +@attr(method='put') +@attr(operation='copy object to itself') +@attr(assertion='fails') +def test_object_copy_to_itself(): + bucket = get_new_bucket() + key = bucket.new_key('foo123bar') + key.set_contents_from_string('foo') + e = assert_raises(boto.exception.S3ResponseError, key.copy, bucket, 'foo123bar') + eq(e.status, 400) + eq(e.reason, 'Bad Request') + eq(e.error_code, 'InvalidRequest') + +@attr(resource='object') +@attr(method='put') +@attr(operation='modify object metadata by copying') +@attr(assertion='fails') +def test_object_copy_to_itself_with_metadata(): + bucket = get_new_bucket() + key = bucket.new_key('foo123bar') + key.set_contents_from_string('foo') + key.copy(bucket, 'foo123bar', {'foo': 'bar'}) + key.close() + + bucket2 = s3.main.get_bucket(bucket.name) + key2 = bucket2.get_key('foo123bar') + md = key2.get_metadata('foo') + eq(md, 'bar') + @attr(resource='object') @attr(method='put') @attr(operation='copy object from different bucket')