@mock_ec2
def test_get_all_spot_instance_requests_filtering():
 conn = boto.connect_ec2()
 request1 = conn.request_spot_instances(price=0.5, image_id=u'ami-abcd1234')
 request2 = conn.request_spot_instances(price=0.5, image_id=u'ami-abcd1234')
 conn.request_spot_instances(price=0.5, image_id=u'ami-abcd1234')
 request1[0].add_tag(u'tag1', u'value1')
 request1[0].add_tag(u'tag2', u'value2')
 request2[0].add_tag(u'tag1', u'value1')
 request2[0].add_tag(u'tag2', u'wrong')
 requests = conn.get_all_spot_instance_requests(filters={u'state': u'active'})
 requests.should.have.length_of(0)
 requests = conn.get_all_spot_instance_requests(filters={u'state': u'open'})
 requests.should.have.length_of(3)
 requests = conn.get_all_spot_instance_requests(filters={u'tag:tag1': u'value1'})
 requests.should.have.length_of(2)
 requests = conn.get_all_spot_instance_requests(filters={u'tag:tag1': u'value1', u'tag:tag2': u'value2'})
 requests.should.have.length_of(1)

@ mock_ec2 def test_get_all_spot_instance_requests_filtering ( ) : conn = boto . connect_ec2 ( ) request1 = conn . request_spot_instances ( price = 0.5 , image_id = u'ami-abcd1234' ) request2 = conn . request_spot_instances ( price = 0.5 , image_id = u'ami-abcd1234' ) conn . request_spot_instances ( price = 0.5 , image_id = u'ami-abcd1234' ) request1 [ 0 ] . add_tag ( u'tag1' , u'value1' ) request1 [ 0 ] . add_tag ( u'tag2' , u'value2' ) request2 [ 0 ] . add_tag ( u'tag1' , u'value1' ) request2 [ 0 ] . add_tag ( u'tag2' , u'wrong' ) requests = conn . get_all_spot_instance_requests ( filters = { u'state' : u'active' } ) requests . should . have . length_of ( 0 ) requests = conn . get_all_spot_instance_requests ( filters = { u'state' : u'open' } ) requests . should . have . length_of ( 3 ) requests = conn . get_all_spot_instance_requests ( filters = { u'tag:tag1' : u'value1' } ) requests . should . have . length_of ( 2 ) requests = conn . get_all_spot_instance_requests ( filters = { u'tag:tag1' : u'value1' , u'tag:tag2' : u'value2' } ) requests . should . have . length_of ( 1 )
test that moto correctly filters spot instance requests .