Add tests for DeleteMarker support
This commit is contained in:
parent
9a861a367d
commit
ac8b8c9a36
@ -1300,6 +1300,12 @@ def test_boto3_list_object_versions():
|
||||
bucket_name = 'mybucket'
|
||||
key = 'key-with-versions'
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
s3.put_bucket_versioning(
|
||||
Bucket=bucket_name,
|
||||
VersioningConfiguration={
|
||||
'Status': 'Enabled'
|
||||
}
|
||||
)
|
||||
items = (six.b('v1'), six.b('v2'))
|
||||
for body in items:
|
||||
s3.put_object(
|
||||
@ -1319,6 +1325,58 @@ def test_boto3_list_object_versions():
|
||||
response['Body'].read().should.equal(items[-1])
|
||||
|
||||
|
||||
@mock_s3
|
||||
def test_boto3_delete_markers():
|
||||
s3 = boto3.client('s3', region_name='us-east-1')
|
||||
bucket_name = 'mybucket'
|
||||
key = 'key-with-versions'
|
||||
s3.create_bucket(Bucket=bucket_name)
|
||||
s3.put_bucket_versioning(
|
||||
Bucket=bucket_name,
|
||||
VersioningConfiguration={
|
||||
'Status': 'Enabled'
|
||||
}
|
||||
)
|
||||
items = (six.b('v1'), six.b('v2'))
|
||||
for body in items:
|
||||
s3.put_object(
|
||||
Bucket=bucket_name,
|
||||
Key=key,
|
||||
Body=body
|
||||
)
|
||||
s3.delete_object(
|
||||
Bucket=bucket_name,
|
||||
Key=key
|
||||
)
|
||||
with assert_raises(ClientError) as e:
|
||||
s3.get_object(
|
||||
Bucket=bucket_name,
|
||||
Key=key
|
||||
)
|
||||
e.response['Error']['Code'].should.equal('NoSuchKey')
|
||||
|
||||
s3.delete_object(
|
||||
Bucket=bucket_name,
|
||||
Key=key,
|
||||
VersionId='2'
|
||||
)
|
||||
response = s3.get_object(
|
||||
Bucket=bucket_name,
|
||||
Key=key
|
||||
)
|
||||
response['Body'].read().should.equal(items[-1])
|
||||
response = s3.list_object_versions(
|
||||
Bucket=bucket_name
|
||||
)
|
||||
response['Versions'].should.have.length_of(2)
|
||||
response['Versions'][-1]['IsLatest'].should.be.true
|
||||
response['Versions'][0]['IsLatest'].should.be.false
|
||||
[(key_metadata['Key'], key_metadata['VersionId'])
|
||||
for key_metadata in response['Versions']].should.equal(
|
||||
[('key-with-versions', '0'), ('key-with-versions', '1')]
|
||||
)
|
||||
|
||||
|
||||
TEST_XML = """\
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ns0:WebsiteConfiguration xmlns:ns0="http://s3.amazonaws.com/doc/2006-03-01/">
|
||||
@ -1337,3 +1395,4 @@ TEST_XML = """\
|
||||
</ns0:RoutingRules>
|
||||
</ns0:WebsiteConfiguration>
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user