'Test replication failover.'

@mock.patch('cinder.objects.Service.is_up', True)
@mock.patch.object(volume_rpcapi.VolumeAPI, 'failover')
@mock.patch.object(cinder.db, 'conditional_update')
@mock.patch.object(objects.ServiceList, 'get_all')
def test_failover(self, mock_get_all, mock_db_update, mock_failover):

    service = fake_service.fake_service_obj(self.context, binary='cinder-volume')
    mock_get_all.return_value = [service]
    mock_db_update.return_value = {'replication_status': 'enabled'}
    volume_api = cinder.volume.api.API()
    volume_api.failover(self.context, host=CONF.host, cluster_name=None)
    mock_failover.assert_called_once_with(self.context, service, None)
