def _do_request(client, method, path, data=None, query=None):
    """Make a request to the endpoint with `data` in the body.

    `client` is a flask test client

    `method` is the request method

    `path` is the path of the request

    `data` a dictionary containing body arguments for non-GET methods that will
    be converted to JSON -- the server will expect valid json, but we want to
    write test cases with invalid input as well.

    `query` a dictionary containing query arguments (ie - those after the ?)
    for the GET method.

    """

    # The arguments for this method are documented at:
    # http://werkzeug.pocoo.org/docs/0.11/test/#werkzeug.test.EnvironBuilder
    return client.open(method=method, path=path, query_string=query, data=data)