From 6f3a0561715134a43a7b1dbf847d1752b67a36d7 Mon Sep 17 00:00:00 2001 From: Christian Wittwer Date: Thu, 5 Jun 2014 11:12:42 +0200 Subject: [PATCH] add test for instance filtering by instance-id --- tests/test_ec2/test_instances.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py index 9a0cd19b..3ee2a279 100644 --- a/tests/test_ec2/test_instances.py +++ b/tests/test_ec2/test_instances.py @@ -106,6 +106,23 @@ def test_get_instances_filtering_by_state(): conn.get_all_instances.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError) +@mock_ec2 +def test_get_instances_filtering_by_instance_id(): + conn = boto.connect_ec2() + reservation = conn.run_instances('ami-1234abcd', min_count=3) + instance1, instance2, instance3 = reservation.instances + + reservations = conn.get_all_instances(filters={'instance-id': instance1.id}) + # get_all_instances should return just instance1 + reservations[0].instances.should.have.length_of(1) + reservations[0].instances[0].id.should.equal(instance1.id) + + reservations = conn.get_all_instances(filters={'instance-id': [instance1.id, instance2.id]}) + # get_all_instances should return two + reservations[0].instances.should.have.length_of(2) + + reservations = conn.get_all_instances(filters={'instance-id': 'non-existing-id'}) + reservations.should.have.length_of(0) @mock_ec2 def test_instance_start_and_stop():