'Tests that we return an empty list if we are unable to successfully
claim resources for the instance'

@mock.patch('nova.scheduler.filter_scheduler.FilterScheduler._cleanup_allocations')
@mock.patch('nova.scheduler.filter_scheduler.FilterScheduler._claim_resources')
@mock.patch('nova.scheduler.filter_scheduler.FilterScheduler._get_all_host_states')
@mock.patch('nova.scheduler.filter_scheduler.FilterScheduler._get_sorted_hosts')
def test_schedule_unsuccessful_claim(self, mock_get_hosts, mock_get_all_states, mock_claim, mock_cleanup):

    spec_obj = objects.RequestSpec(num_instances=1, flavor=objects.Flavor(memory_mb=512, root_gb=512, ephemeral_gb=0, swap=0, vcpus=1), project_id=uuids.project_id, instance_group=None)
    host_state = mock.Mock(spec=host_manager.HostState, host=mock.sentinel.host, uuid=uuids.cn1)
    all_host_states = [host_state]
    mock_get_all_states.return_value = all_host_states
    mock_get_hosts.return_value = all_host_states
    mock_claim.return_value = False
    instance_uuids = [uuids.instance]
    alloc_reqs_by_rp_uuid = {uuids.cn1: [mock.sentinel.alloc_req]}
    ctx = mock.Mock()
    selected_hosts = self.driver._schedule(ctx, spec_obj, instance_uuids, alloc_reqs_by_rp_uuid, mock.sentinel.provider_summaries)
    mock_get_all_states.assert_called_once_with(ctx.elevated.return_value, spec_obj, mock.sentinel.provider_summaries)
    mock_get_hosts.assert_called_once_with(spec_obj, all_host_states, 0)
    mock_claim.assert_called_once_with(ctx.elevated.return_value, spec_obj, uuids.instance, [mock.sentinel.alloc_req])
    self.assertEqual([], selected_hosts)
    mock_cleanup.assert_called_once_with([])
    self.assertFalse(host_state.consume_from_request.called)
