'Tests the case that the instance does not have a host and was not
deleted while building, so conductor put it into cell0 so the API has
to delete the instance from cell0.'

@mock.patch('nova.compute.utils.notify_about_instance_delete')
@mock.patch('nova.objects.Instance.destroy')
def test_delete_instance_from_cell0(self, destroy_mock, notify_mock):

    instance = self._create_instance_obj({'host': None})
    cell0 = objects.CellMapping(uuid=objects.CellMapping.CELL0_UUID)
    with test.nested(mock.patch.object(self.compute_api, '_delete_while_booting', return_value=False), mock.patch.object(self.compute_api, '_lookup_instance', return_value=(cell0, instance))) as (_delete_while_booting, _lookup_instance):
        self.compute_api._delete(self.context, instance, 'delete', mock.NonCallableMock())
        _delete_while_booting.assert_called_once_with(self.context, instance)
        _lookup_instance.assert_called_once_with(self.context, instance.uuid)
        notify_mock.assert_called_once_with(self.compute_api.notifier, self.context, instance)
        destroy_mock.assert_called_once_with()
