def get_request_url(base_url, resource_path, query):
    """Helper method to construct the Url for a server request. Combined the
    base Url with the resource path and appends the query parameters (if not
    empty).

    Parameters
    ----------
    base_url: string
        Base Url for the server
    resource_path: string
        Path for requested resource
    query: dict
        Dictionary of query parameters

    Returns
    -------
    string
    """
    url = base_url
    # Remove trailing slashes from base Url.
    while url.endswith('/'):
        url = url[:-1]
    # Append resource path to base Url. This assumes that the resource path
    # starts with a '/'
    url += resource_path
    # Append query parameter to Url if the dictionary is not empty
    if len(query) > 0:
        # Remove trailing slashes from base Url.
        while url.endswith('/'):
            url = url[:-1]
        delim = '?'
        for key in sorted(query.keys()):
            url += delim + key + '=' + query[key]
            delim = '&'
    return url