Ejemplo n.º 1
0
def get_build_reports(project_name, release_name):
    """Get all summary of all the builds for a particular release."""
    limit = 15
    if request.args.get("limit"):
        try:
            limit = int(request.args.get("limit"))
        except:
            pass
    groupType = "SERIAL"
    if request.args.get("groupType"):
        groupType = request.args.get("groupType")
    project_id, release_id, build_id = Project.lookup_project_release_build_ids(project_name, release_name, None, get_all_builds=True, limit=limit)
    report = {}
    report['name'] = "Release Report for {} {}".format(project_name, release_name)
    report['builds'] = []
    report['grouptype'] = groupType
    if build_id is None:
        return JsonResponse({})
    for build_object in build_id:
        testrun_group = TestrunGroup()
        testrun_group.name = "Build Report for {} {} Build {}".format(project_name, release_name, build_object['name'])
        testrun_group.grouptype = groupType
        testrun_group.testruns = Testrun.objects(build__buildId=build_object['id']).order_by("-dateCreated")
        report['builds'].append(testrun_group)
    return JsonResponse(report)
Ejemplo n.º 2
0
def delete_testrun(testrun_id):
    """Remove a testrun."""
    orig = Testrun.objects(id=testrun_id).first()

    # delete the reference from any testrun groups
    trdbref = bson.DBRef('testruns', bson.ObjectId("531e4d26ded43258823d9c3a"))
    TestrunGroup.objects(__raw__={'testruns': {'$elemMatch': trdbref}}).update(pull__testruns=trdbref)

    # add an event
    events.DeleteEvent(orig)

    orig.delete()
    return JsonResponse(orig)
Ejemplo n.º 3
0
def get_tps_report(project_name, release_name, testplan_name):
    """Get all summary of all the testruns run against a particular build."""
    project_id, release_id, _ = Project.lookup_project_release_build_ids(project_name, release_name, None)
    testplan = TestPlan.objects(project__id=project_id, name=testplan_name)
    if len(testplan) > 0:
        testplan = testplan[0]
        report = TestrunGroup()
        report.name = "{} Summary for {}".format(testplan_name, release_name)
        report.grouptype = "SERIAL"
        report.testruns = []
        report.testruns.extend(Testrun.objects(project__id=project_id, release__releaseId=release_id, testplanId=testplan.id).order_by('-dateCreated').limit(50))
        report.testruns.reverse()

        return JsonResponse(report)
    else:
        return JsonResponse({})
Ejemplo n.º 4
0
def get_build_report(project_name, release_name, build_name):
    """Get all summary of all the testruns run against a particular build."""
    project_id, release_id, build_id = Project.lookup_project_release_build_ids(project_name, release_name, build_name)

    report = TestrunGroup()
    report.name = "Build Report for {} {} Build {}".format(project_name, release_name, build_name)
    report.grouptype = "PARALLEL"
    report.testruns = []
    testplans = []
    for testrun in Testrun.objects(build__buildId=build_id).order_by("-dateCreated"):
        assert isinstance(testrun, Testrun)
        if testrun.testplanId not in testplans:
            report.testruns.append(testrun)
            testplans.append(testrun.testplanId)

    return JsonResponse(report)
Ejemplo n.º 5
0
def add_testrun_to_testrun_group(testrungroup_id, testrun_id):
    """Add a testrun to a testrun group"""
    orig = TestrunGroup.objects(id=ObjectId(testrungroup_id)).first()
    testrun = Testrun.objects(id=ObjectId(testrun_id)).first()
    if (not hasattr(orig, 'testruns')) or orig.testruns is None:
        orig.testruns = []
    orig.testruns.append(testrun)
    orig.save()
    return JsonResponse(orig)
Ejemplo n.º 6
0
def remove_testrun_from_testrun_group(testrungroup_id, testrun_id):
    """Remove a testrun from a testrun group"""
    orig = TestrunGroup.objects(id=ObjectId(testrungroup_id)).first()
    real_testrunid = ObjectId(testrun_id)
    index = -1
    for i in range(len(orig.testruns)):
        if orig.testruns[i].id == real_testrunid:
            index = i
            break
    if index >= 0:
        del orig.testruns[index]
        orig.save()
    return JsonResponse(orig)
Ejemplo n.º 7
0
def get_build_report(project_name, release_name, build_name):
    """Get all summary of all the testruns run against a particular build."""
    project_id, release_id, build_id = Project.lookup_project_release_build_ids(project_name, release_name, build_name)

    report = TestrunGroup()
    report.name = "Build Report for {} {} Build {}".format(project_name, release_name, build_name)
    report.grouptype = "PARALLEL"
    report.testruns = []
    testplans = []
    if build_id is None:
        return JsonResponse(None)
    for testrun in Testrun.objects(build__buildId=build_id).order_by("-dateCreated"):
        assert isinstance(testrun, Testrun)
        if testrun.testplanId not in testplans:
            report.testruns.append(testrun)
            testplans.append(testrun.testplanId)
    if report.state() == "FINISHED" and not report.finished:
        report.finished = datetime.datetime.utcnow()
        # report.save() Warning, be careful not to do this, build reports don't get saved
        # this will create a new testrungroup every time the build report is
        # queried
    return JsonResponse(report)
Ejemplo n.º 8
0
def delete_testrungroup(testrungroup_id):
    """Remove a testrun group"""
    orig = TestrunGroup.objects(id=testrungroup_id).first()
    orig.delete()
    return JsonResponse(orig)
Ejemplo n.º 9
0
def update_testrungroup(testrungroup_id):
    """Update a testrun group's properties."""
    orig = TestrunGroup.objects(id=testrungroup_id).first()
    deserialize_that(read_request(), orig)
    orig.save()
    return JsonResponse(orig)
Ejemplo n.º 10
0
def get_testrungroup_by_id(testrungroup_id):
    """Find a testrungroup by it's id."""
    return JsonResponse(TestrunGroup.objects(id=testrungroup_id).first())