]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
test two cases in copying object to itself
authorYehuda Sadeh <yehuda@inktank.com>
Fri, 15 Jun 2012 00:07:46 +0000 (17:07 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 15 Jun 2012 00:07:46 +0000 (17:07 -0700)
 - should fail when not trying to change metadata
 - should succeed when changing metadata; also verify metadata

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
s3tests/functional/test_s3.py

index 0fbd7254c735f2bdd6720aa4fe713e774d593287..3806d69d6562265860bb98451e9d07fa76f0263c 100644 (file)
@@ -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')