'Test successful manage snapshot 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.'

@mock.patch('cinder.volume.rpcapi.VolumeAPI.manage_existing_snapshot')
@mock.patch('cinder.volume.api.API.create_snapshot_in_db')
@mock.patch('cinder.db.sqlalchemy.api.service_get')
def test_manage_snapshot_ok(self, mock_db, mock_create_snapshot, mock_rpcapi):

    mock_db.return_value = fake_service.fake_service_obj(self._admin_ctxt, binary='cinder-volume')
    body = {'snapshot': {'volume_id': fake.VOLUME_ID, 'ref': 'fake_ref'}}
    res = self._get_resp_post(body)
    self.assertEqual(http_client.ACCEPTED, res.status_int, res)
    mock_db.assert_called_once_with(mock.ANY, None, host='fake_host', binary='cinder-volume', cluster_name=None)
    self.assertEqual(1, mock_create_snapshot.call_count)
    args = mock_create_snapshot.call_args[0]
    named_args = mock_create_snapshot.call_args[1]
    self.assertEqual(fake.VOLUME_ID, args[1].get('id'))
    self.assertFalse(named_args['commit_quota'])
    self.assertEqual(1, mock_rpcapi.call_count)
    args = mock_rpcapi.call_args[0]
    self.assertEqual('fake_ref', args[2])
