@mock_ec2
def test_cancel_spot_instance_request():
    conn = boto.connect_ec2()
    conn.request_spot_instances(price=0.5, image_id='ami-abcd1234')
    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    with assert_raises(JSONResponseError) as ex:
        conn.cancel_spot_instance_requests([requests[0].id], dry_run=True)
    ex.exception.reason.should.equal('DryRunOperation')
    ex.exception.status.should.equal(400)
    ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the CancelSpotInstance operation: Request would have succeeded, but DryRun flag is set')
    conn.cancel_spot_instance_requests([requests[0].id])
    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(0)
@mock_ec2
def test_cancel_spot_instance_request():
    conn = boto.connect_ec2()
    conn.request_spot_instances(price=0.5, image_id='ami-abcd1234')
    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(1)
    with assert_raises(JSONResponseError) as ex:
        conn.cancel_spot_instance_requests([requests[0].id], dry_run=True)
    ex.exception.reason.should.equal('DryRunOperation')
    ex.exception.status.should.equal(400)
    ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the CancelSpotInstance operation: Request would have succeeded, but DryRun flag is set')
    conn.cancel_spot_instance_requests([requests[0].id])
    requests = conn.get_all_spot_instance_requests()
    requests.should.have.length_of(0)