some more tests to bump coverage
This commit is contained in:
parent
127a0d5993
commit
2d98a9caef
@ -1,37 +1,10 @@
|
||||
from .responses import handler
|
||||
|
||||
|
||||
def sts_handler(uri, body, headers):
|
||||
return GET_SESSION_TOKEN_RESULT
|
||||
|
||||
url_bases = [
|
||||
"https?://dynamodb.us-east-1.amazonaws.com",
|
||||
"https?://sts.amazonaws.com",
|
||||
]
|
||||
|
||||
url_paths = {
|
||||
"{0}/": handler,
|
||||
}
|
||||
|
||||
|
||||
GET_SESSION_TOKEN_RESULT = """
|
||||
<GetSessionTokenResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
|
||||
<GetSessionTokenResult>
|
||||
<Credentials>
|
||||
<SessionToken>
|
||||
AQoEXAMPLEH4aoAH0gNCAPyJxz4BlCFFxWNE1OPTgk5TthT+FvwqnKwRcOIfrRh3c/L
|
||||
To6UDdyJwOOvEVPvLXCrrrUtdnniCEXAMPLE/IvU1dYUg2RVAJBanLiHb4IgRmpRV3z
|
||||
rkuWJOgQs8IZZaIv2BXIa2R4OlgkBN9bkUDNCJiBeb/AXlzBBko7b15fjrBs2+cTQtp
|
||||
Z3CYWFXG8C5zqx37wnOE49mRl/+OtkIKGO7fAE
|
||||
</SessionToken>
|
||||
<SecretAccessKey>
|
||||
wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
|
||||
</SecretAccessKey>
|
||||
<Expiration>2011-07-11T19:55:29.611Z</Expiration>
|
||||
<AccessKeyId>AKIAIOSFODNN7EXAMPLE</AccessKeyId>
|
||||
</Credentials>
|
||||
</GetSessionTokenResult>
|
||||
<ResponseMetadata>
|
||||
<RequestId>58c5dbae-abef-11e0-8cfe-09039844ac7d</RequestId>
|
||||
</ResponseMetadata>
|
||||
</GetSessionTokenResponse>"""
|
||||
|
@ -22,8 +22,12 @@ class AmisResponse(object):
|
||||
def deregister_image(self):
|
||||
ami_id = self.querystring.get('ImageId')[0]
|
||||
success = ec2_backend.deregister_image(ami_id)
|
||||
template = Template(DESCRIBE_IMAGES_RESPONSE)
|
||||
return template.render(success=str(success).lower())
|
||||
template = Template(DEREGISTER_IMAGE_RESPONSE)
|
||||
rendered = template.render(success=str(success).lower())
|
||||
if success:
|
||||
return rendered
|
||||
else:
|
||||
return rendered, dict(status=404)
|
||||
|
||||
def describe_image_attribute(self):
|
||||
raise NotImplementedError('AMIs.describe_image_attribute is not yet implemented')
|
||||
|
@ -13,6 +13,8 @@ class ElasticBlockStore(object):
|
||||
device_path = self.querystring.get('Device')[0]
|
||||
|
||||
attachment = ec2_backend.attach_volume(volume_id, instance_id, device_path)
|
||||
if not attachment:
|
||||
return "", dict(status=404)
|
||||
template = Template(ATTACHED_VOLUME_RESPONSE)
|
||||
return template.render(attachment=attachment)
|
||||
|
||||
|
@ -89,8 +89,6 @@ def key_response(uri_info, body, headers):
|
||||
key = s3_backend.get_key(bucket_name, key_name)
|
||||
if key:
|
||||
return "", dict(etag=key.etag)
|
||||
else:
|
||||
return ""
|
||||
elif method == 'HEAD':
|
||||
key = s3_backend.get_key(bucket_name, key_name)
|
||||
if key:
|
||||
|
@ -19,6 +19,8 @@ def test_ami_create_and_delete():
|
||||
success = conn.deregister_image(image)
|
||||
success.should.be.true
|
||||
|
||||
success = conn.deregister_image.when.called_with(image).should.throw(EC2ResponseError)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_ami_create_from_missing_instance():
|
||||
|
@ -46,9 +46,15 @@ def test_volume_attach_and_detach():
|
||||
volume.update()
|
||||
volume.volume_state().should.equal('available')
|
||||
|
||||
volume.attach.when.called_with(
|
||||
'i-1234abcd', "/dev/sdh").should.throw(EC2ResponseError)
|
||||
|
||||
conn.detach_volume.when.called_with(
|
||||
volume.id, instance.id, "/dev/sdh").should.throw(EC2ResponseError)
|
||||
|
||||
conn.detach_volume.when.called_with(
|
||||
volume.id, 'i-1234abcd', "/dev/sdh").should.throw(EC2ResponseError)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_create_snapshot():
|
||||
|
Loading…
Reference in New Issue
Block a user