Esempio n. 1
0
def test_update(proj, build_id, run, test):
    r = _get_run(proj, build_id, run)
    _authenticate_runner(r)
    t = Test.query.filter_by(name=test).filter(Test.run.has(Run.id == r.id))
    context = request.args.get("context")
    if context:
        t = t.filter(Test.context == context)
    t = t.first_or_404()

    json = request.get_json()
    if json:
        msg = json.get("message")
        status = json.get("status")
        results = json.get("results", [])
        storage = Storage()

        if msg:
            with storage.console_logfd(r, "a") as f:
                f.write(msg)
        if results:
            for tr in results:
                create_test_result(t, tr)
            db.session.commit()
        if status:
            run_status = t.set_status(status)
            db.session.commit()
            if run_status in (BuildStatus.PASSED, BuildStatus.FAILED):
                storage.copy_log(r)
            if run_status is not None:
                with r.build.locked():
                    t.run.set_status(run_status)
                    if r.complete:
                        _handle_triggers(storage, r)

    return jsendify({"complete": t.run.complete})
Esempio n. 2
0
def test_create(proj, build_id, run, test):
    r = _get_run(proj, build_id, run)
    _authenticate_runner(r)
    context = ""
    status = results = None
    json = request.get_json()
    if json:
        context = json.get("context")
        status = json.get("status")
        results = json.get("results")

    t = Test(r, test, context)
    db.session.add(t)

    if status:
        t.status = status

    if results:
        db.session.flush()
        for tr in results:
            create_test_result(t, tr)

    db.session.commit()
    return jsendify({})
Esempio n. 3
0
def test_get(proj, build_id, run, test):
    r = _get_run(proj, build_id, run)
    t = Test.query.filter_by(run_id=r.id, name=test).first_or_404()
    return jsendify({"test": t.as_json(detailed=True)})
Esempio n. 4
0
def test_list(proj, build_id, run):
    r = _get_run(proj, build_id, run)
    return jsendify({"tests": [x.as_json(detailed=False) for x in r.tests]})