def update_existing_entry(project): try: job = Job.query.filter( Job.status == Status.in_progress, )[0] except IndexError: return create_new_entry(project) job.date_modified = datetime.utcnow() job.status = Status.finished job.result = Result.failed if random.randint(0, 3) == 1 else Result.passed job.date_finished = datetime.utcnow() db.session.add(job) jobstep = JobStep.query.filter(JobStep.job == job).first() if jobstep: test_results = [] for _ in xrange(50): if job.result == Result.failed: result = Result.failed if random.randint(0, 3) == 1 else Result.passed else: result = Result.passed test_results.append(mock.test_result(jobstep, result=result)) TestResultManager(jobstep).save(test_results) if job.status == Status.finished: job.build.status = job.status job.build.result = job.result job.build.date_finished = job.date_finished job.build.date_modified = job.date_finished db.session.add(job.build) return job
def update_existing_entry(project): try: job = Job.query.filter(Job.status == Status.in_progress, )[0] except IndexError: return create_new_entry(project) job.status = Status.finished job.result = Result.failed if random.randint(0, 3) == 1 else Result.passed job.date_finished = datetime.utcnow() db.session.add(job) publish_job_update(job) jobstep = JobStep.query.filter(JobStep.job == job).first() if jobstep: test_results = [] for _ in xrange(50): if job.result == Result.failed: result = Result.failed if random.randint( 0, 3) == 1 else Result.passed else: result = Result.passed test_results.append(mock.test_result(jobstep, result=result)) TestResultManager(jobstep).save(test_results) if job.status == Status.finished: job.build.status = job.status job.build.result = job.result job.build.date_finished = job.date_finished db.session.add(job.build) publish_build_update(job.build) return job