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)
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({})
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)
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)