add test for creating already existing keypair
This commit is contained in:
parent
ddfe478479
commit
8b7c3a3312
@ -1,6 +1,7 @@
|
|||||||
import boto
|
import boto
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
|
from boto.exception import EC2ResponseError
|
||||||
from moto import mock_ec2
|
from moto import mock_ec2
|
||||||
|
|
||||||
|
|
||||||
@ -15,3 +16,15 @@ def test_key_pairs_create():
|
|||||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||||
kp = conn.create_key_pair('foo')
|
kp = conn.create_key_pair('foo')
|
||||||
assert kp.material.startswith('---- BEGIN RSA PRIVATE KEY ----')
|
assert kp.material.startswith('---- BEGIN RSA PRIVATE KEY ----')
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_key_pairs_create_exist():
|
||||||
|
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||||
|
kp = conn.create_key_pair('foo')
|
||||||
|
assert kp.material.startswith('---- BEGIN RSA PRIVATE KEY ----')
|
||||||
|
# Call get_all_instances with a bad id should raise an error
|
||||||
|
conn.create_key_pair.when.called_with('foo').should.throw(
|
||||||
|
EC2ResponseError,
|
||||||
|
"The keypair 'foo' already exists."
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user