From 8a0a10b0d1ea459763206b80dbff56cf30674d97 Mon Sep 17 00:00:00 2001 From: Hugo Lopes Tavares Date: Tue, 4 Nov 2014 16:56:56 -0500 Subject: [PATCH] Add support to filtering instances by source-dest-check --- moto/ec2/utils.py | 1 + tests/test_ec2/test_instances.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/moto/ec2/utils.py b/moto/ec2/utils.py index 7251ff0ba..9a91299b8 100644 --- a/moto/ec2/utils.py +++ b/moto/ec2/utils.py @@ -273,6 +273,7 @@ filter_dict_attribute_mapping = { 'instance-state-name': 'state', 'instance-id': 'id', 'state-reason-code': '_state_reason.code', + 'source-dest-check': 'source_dest_check', } def get_instance_value(instance, instance_attr): diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py index 150544b49..f7b0ceaca 100644 --- a/tests/test_ec2/test_instances.py +++ b/tests/test_ec2/test_instances.py @@ -153,6 +153,24 @@ def test_get_instances_filtering_by_reason_code(): 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_source_dest_check(): + conn = boto.connect_ec2() + reservation = conn.run_instances('ami-1234abcd', min_count=2) + instance1, instance2 = reservation.instances + conn.modify_instance_attribute(instance1.id, attribute='sourceDestCheck', value=False) + + source_dest_check_false = conn.get_all_instances(filters={'source-dest-check': 'false'}) + source_dest_check_true = conn.get_all_instances(filters={'source-dest-check': 'true'}) + + source_dest_check_false[0].instances.should.have.length_of(1) + source_dest_check_false[0].instances[0].id.should.equal(instance1.id) + + source_dest_check_true[0].instances.should.have.length_of(1) + source_dest_check_true[0].instances[0].id.should.equal(instance2.id) + + @mock_ec2 def test_get_instances_filtering_by_tag(): conn = boto.connect_ec2()