Esempio n. 1
0
def results_summary(project_id, run_id):
    """
    Returns JSON response containing mock run status.
    """
    results = mocks.results()
    summary = results["summary"]
    return utils.jsonify(summary)
Esempio n. 2
0
def results_status(project_id, run_id):
    """
    Returns JSON response containing mock run status.
    """
    results = mocks.results()
    status = results["summary"]["status"]
    return utils.jsonify(dict(status=status))
Esempio n. 3
0
def publish_run(project_id, run_id):
    """
    Return JSON response containing mock publish data.
    """
    state = request.args.get("public")
    if not state:
        abort(400)
    return utils.jsonify(mocks.publish())
Esempio n. 4
0
def new_project():
    """
    Returns JSON response containing mock response to creating
    an AppThwack project.
    """
    name = request.form.get("name")
    project_type = request.form.get("type")
    if not all((name, project_type)):
        abort(400)
    return utils.jsonify(mocks.new_project())
Esempio n. 5
0
def results(project_id, run_id):
    """
    Returns JSON response containing mock run results.
    Supports:
        - ?format=archive: Download generic results archive.
    """
    fmt = request.args.get("format")
    if fmt and fmt == "archive":
        directory = current_app.config["DOWNLOAD_FOLDER"]
        return send_from_directory(directory, "results.zip")
    return utils.jsonify(mocks.results())
Esempio n. 6
0
def schedule_run():
    """
    Returns JSON response containing mock run data.
    Validates:
        Form Data:
            - project: (int) project id which we're running
            - name: (string) name of run
            - app: (int) file_id returned from /file upload
    """
    project = request.form.get("project")
    name = request.form.get("name")
    app = request.form.get("app")
    if not all((project, name, app)):
        abort(400)
    return utils.jsonify(mocks.run_id())
Esempio n. 7
0
def upload_file():
    """
    Returns JSON response containing mock file upload data.
    Validates:
        Form Data:
            - file: (file) File being uploaded is .apk or .ipa.
            - name: (string) File name used by AppThwack.
    """
    f = request.files.get("file")
    if not f or not utils.valid_ext(f.filename):
        abort(400)
    name = request.form.get("name")
    if not name:
        abort(400)
    return utils.jsonify(mocks.file_id())
Esempio n. 8
0
 def jsonify_unhandled_exceptions(e):
     response = utils.jsonify(dict(message=str(e)))
     response.status_code = getattr(e, 'code', 500)
     return response
Esempio n. 9
0
def devices():
    """
    Returns JSON response containing mock list of devices.
    """
    return utils.jsonify(mocks.devices())
Esempio n. 10
0
def devicepool(project_id):
    """
    Returns JSON response containing mock devicepool data.
    """
    return utils.jsonify(mocks.devicepool())
Esempio n. 11
0
def project():
    """
    Returns JSON response containing mock project data.
    """
    return utils.jsonify(mocks.project())
Esempio n. 12
0
def compatibility():
    """
    Returns JSON response containing mock compatibility information
    regarding a test upload and device pool.
    """
    return utils.jsonify(mocks.compatibility())
Esempio n. 13
0
def runs(project_id):
    """
    Returns JSON response containing mock list of all runs of a project.
    """
    return utils.jsonify(mocks.runs())
Esempio n. 14
0
def cancel_run(project_id, run_id):
    """
    Returns JSON response containing mock cancellation result.
    """
    return utils.jsonify(mocks.cancellation())