Test filtering get_instances by reason code
This commit is contained in:
parent
6963866c7e
commit
c0049578cb
@ -268,7 +268,6 @@ filter_dict_attribute_mapping = {
|
||||
'instance-state-name': 'state',
|
||||
'instance-id': 'id',
|
||||
'state-reason-code': '_state_reason.code',
|
||||
'state-reason-message': '_state_reason.message'
|
||||
}
|
||||
|
||||
def get_instance_value(instance, instance_attr):
|
||||
|
@ -135,6 +135,24 @@ def test_get_instances_filtering_by_instance_id():
|
||||
reservations = conn.get_all_instances(filters={'instance-id': 'non-existing-id'})
|
||||
reservations.should.have.length_of(0)
|
||||
|
||||
@mock_ec2
|
||||
def test_get_instances_filtering_by_reason_code():
|
||||
conn = boto.connect_ec2()
|
||||
reservation = conn.run_instances('ami-1234abcd', min_count=3)
|
||||
instance1, instance2, instance3 = reservation.instances
|
||||
instance1.stop()
|
||||
instance2.terminate()
|
||||
|
||||
reservations = conn.get_all_instances(filters={'state-reason-code': 'Client.UserInitiatedShutdown'})
|
||||
# get_all_instances should return instance1 and instance2
|
||||
reservations[0].instances.should.have.length_of(2)
|
||||
set([instance1.id, instance2.id]).should.equal(set([i.id for i in reservations[0].instances]))
|
||||
|
||||
reservations = conn.get_all_instances(filters={'state-reason-code': ''})
|
||||
# get_all_instances should return instance 3
|
||||
reservations[0].instances.should.have.length_of(1)
|
||||
reservations[0].instances[0].id.should.equal(instance3.id)
|
||||
|
||||
@mock_ec2
|
||||
def test_get_instances_filtering_by_tag():
|
||||
conn = boto.connect_ec2()
|
||||
|
Loading…
Reference in New Issue
Block a user