Merge pull request #162 from andresriancho/master

Fix block device mapping #160
This commit is contained in:
Steve Pulec 2014-08-20 07:39:24 -04:00
commit 195505948b
3 changed files with 84 additions and 1 deletions

View file

@ -3,6 +3,7 @@ from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto.ec2.models import ec2_backend
@mock_ec2
@ -76,3 +77,24 @@ def test_create_snapshot():
# Deleting something that was already deleted should throw an error
snapshot.delete.when.called_with().should.throw(EC2ResponseError)
@mock_ec2
def test_modify_attribute_blockDeviceMapping():
"""
Reproduces the missing feature explained at [0], where we want to mock a
call to modify an instance attribute of type: blockDeviceMapping.
[0] https://github.com/spulec/moto/issues/160
"""
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
instance = reservation.instances[0]
instance.modify_attribute('blockDeviceMapping', {'/dev/sda1': True})
instance = ec2_backend.get_instance(instance.id)
instance.block_device_mapping.should.have.key('/dev/sda1')
instance.block_device_mapping['/dev/sda1'].delete_on_termination.should.be(True)