def METHOD_NAME(name):
    cursor = dbcursor_query(
        "SELECT EXISTS"
        " (SELECT * FROM test WHERE available AND name = %s)",
        [name])
    exists = cursor.fetchone()[0]
    cursor.close()
    if not exists:
        return not_found()
    spec = request.args.get('spec')
    if spec is None:
        return bad_request("No test spec provided")
    try:
        returncode, stdout, stderr = pscheduler.plugin_invoke(
            "test", name, "spec-is-valid", stdin=spec)
        if returncode != 0:
            return error("Unable to validate test spec: %s" % (stderr))
        validate_json = pscheduler.json_load(stdout, max_schema=1)
        return ok_json(validate_json, sanitize=False)
    except Exception as ex:
        return error("Unable to validate test spec: %s" % (str(ex)))