'Test successful manage volume execution.
Tests for correct operation when valid arguments are passed in the
request body.  We ensure that cinder.volume.api.API.manage_existing got
called with the correct arguments, and that we return the correct HTTP
code to the caller.'

@ddt.data(False, True)
@mock.patch('cinder.volume.api.API.manage_existing', wraps=api_manage)
@mock.patch('cinder.api.openstack.wsgi.Controller.validate_name_and_description')
def test_manage_volume_ok(self, cluster, mock_validate, mock_api_manage):

    body = {'volume': {'host': 'host_ok', 'ref': 'fake_ref'}}
    if cluster:
        body['volume']['cluster'] = 'cluster'
    res = self._get_resp_post(body)
    self.assertEqual(http_client.ACCEPTED, res.status_int)
    self.assertEqual(1, mock_api_manage.call_count)
    args = mock_api_manage.call_args[0]
    self.assertEqual(body['volume']['host'], args[1])
    self.assertIsNone(args[2])
    self.assertEqual(body['volume']['ref'], args[3])
    self.assertTrue(mock_validate.called)
