]> git-server-git.apps.pok.os.sepia.ceph.com Git - s3-tests.git/commitdiff
Merge pull request #49 from andrewgaul/copy-bucket-key-not-found
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 18 Dec 2015 17:50:20 +0000 (09:50 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 18 Dec 2015 17:50:20 +0000 (09:50 -0800)
Copy tests for non-existent buckets and keys

Reviewed-by: Yehuda Sadeh <yehuda@redhat.com>
1  2 
s3tests/functional/test_s3.py

index b9c3537a13ae1dece237be055f284a344e051893,568bcd98178b3642ac78661a7522f32be1dd6fdd..1fa0d40cc33ff52a0eb238a4f8f8e719eb4eeed6
@@@ -4644,22 -4458,41 +4644,42 @@@ def test_object_copy_retaining_metadata
  @attr(method='put')
  @attr(operation='copy object and replace metadata')
  def test_object_copy_replacing_metadata():
 -    bucket = get_new_bucket()
 -    key = bucket.new_key('foo123bar')
 -    key.set_metadata('key1', 'value1')
 -    key.set_metadata('key2', 'value2')
 -    key.content_type = 'audio/ogg'
 -    key.set_contents_from_string('foo')
 +    for size in [3, 1024 * 1024]:
 +        bucket = get_new_bucket()
 +        key = bucket.new_key('foo123bar')
 +        key.set_metadata('key1', 'value1')
 +        key.set_metadata('key2', 'value2')
 +        key.content_type = 'audio/ogg'
 +        key.set_contents_from_string(str(bytearray(size)))
  
 -    metadata = {'key3': 'value3', 'key1': 'value4'}
 -    content_type = 'audio/mpeg'
 -    bucket.copy_key('bar321foo', bucket.name, 'foo123bar', metadata=metadata, headers={'Content-Type': content_type})
 -    key2 = bucket.get_key('bar321foo')
 -    eq(key2.size, 3)
 -    eq(key2.metadata, metadata)
 -    eq(key2.content_type, content_type)
 +        metadata = {'key3': 'value3', 'key1': 'value4'}
 +        content_type = 'audio/mpeg'
 +        bucket.copy_key('bar321foo', bucket.name, 'foo123bar', metadata=metadata, headers={'Content-Type': content_type})
 +        key2 = bucket.get_key('bar321foo')
 +        eq(key2.size, size)
 +        eq(key2.metadata, metadata)
 +        eq(key2.content_type, content_type)
  
+ @attr(resource='object')
+ @attr(method='put')
+ @attr(operation='copy from non-existent bucket')
+ def test_object_copy_bucket_not_found():
+     bucket = get_new_bucket()
+     e = assert_raises(boto.exception.S3ResponseError, bucket.copy_key, 'foo123bar', bucket.name + "-fake", 'bar321foo')
+     eq(e.status, 404)
+     eq(e.reason, 'Not Found')
+     eq(e.error_code, 'NoSuchBucket')
+ @attr(resource='object')
+ @attr(method='put')
+ @attr(operation='copy from non-existent object')
+ def test_object_copy_key_not_found():
+     bucket = get_new_bucket()
+     e = assert_raises(boto.exception.S3ResponseError, bucket.copy_key, 'foo123bar', bucket.name, 'bar321foo')
+     eq(e.status, 404)
+     eq(e.reason, 'Not Found')
+     eq(e.error_code, 'NoSuchKey')
  def transfer_part(bucket, mp_id, mp_keyname, i, part):
      """Transfer a part of a multipart upload. Designed to be run in parallel.
      """