'Ensure exception is raised when malformed packet is received.'

def test_rpc_client_error_in_receive_fragment(self):

    mock_sendrcd = self.mock_object(coho.Client, '_sendrecord')
    mock_socket = self.mock_object(socket, 'socket')
    mock_socket.return_value.recv.return_value = INVALID_HEADER_BIN
    rpc_client = coho.CohoRPCClient(ADDR, RPC_PORT)
    with self.assertRaisesRegex(exception.CohoException, 'Invalid    response    header.*'):
        rpc_client.create_snapshot('src', 'dest', 0)
    self.assertTrue(mock_sendrcd.called)
    mock_socket.assert_has_calls([mock.call(socket.AF_INET, socket.SOCK_STREAM), mock.call().connect((ADDR, RPC_PORT)), mock.call().recv(4)])
