'This test ensures that the RPC client logic is correct.
When the RPC client\'s make_call function is called it creates
a packet and sends it to the Coho cluster RPC server. This test
ensures that the functions needed to complete the process are
called in the proper order with valid arguments.'

def test_rpc_client_make_call_proper_order(self):

    mock_packer = self.mock_object(xdrlib, 'Packer')
    mock_unpacker = self.mock_object(xdrlib, 'Unpacker')
    mock_unpacker.return_value.unpack_uint.return_value = 0
    mock_socket = self.mock_object(socket, 'socket')
    mock_init_call = self.mock_object(coho.Client, 'init_call')
    mock_init_call.return_value = (1, 2)
    mock_sendrecord = self.mock_object(coho.Client, '_sendrecord')
    mock_recvrecord = self.mock_object(coho.Client, '_recvrecord')
    mock_recvrecord.return_value = 'test_reply'
    mock_unpack_replyheader = self.mock_object(coho.Client, 'unpack_replyheader')
    mock_unpack_replyheader.return_value = (123, 1)
    rpc_client = coho.CohoRPCClient(ADDR, RPC_PORT)
    rpc_client.create_volume_from_snapshot('src', 'dest')
    self.assertTrue(mock_sendrecord.called)
    self.assertTrue(mock_unpack_replyheader.called)
    mock_packer.assert_has_calls([mock.call().reset()])
    mock_unpacker.assert_has_calls([mock.call().reset('test_reply'), mock.call().unpack_uint()])
    mock_socket.assert_has_calls([mock.call(socket.AF_INET, socket.SOCK_STREAM), mock.call().connect((ADDR, RPC_PORT))])
    mock_init_call.assert_has_calls([mock.call(coho.COHO1_CREATE_VOLUME_FROM_SNAPSHOT, [(six.b('src'), mock_packer().pack_string), (six.b('dest'), mock_packer().pack_string)])])
