def test_simple(self): project = self.create_project() plan = self.create_plan() plan.projects.append(project) step = self.create_step(plan) build = self.create_build(project=project) job = self.create_job(build=build, status=Status.queued) self.create_job_plan(job, plan) option = ItemOption( item_id=step.id, name='build.timeout', value='5', ) db.session.add(option) db.session.commit() jobphase = self.create_jobphase(job) jobstep = self.create_jobstep(jobphase) assert not has_timed_out(jobstep, plan) jobstep.status = Status.in_progress jobstep.date_started = datetime.utcnow() db.session.add(jobstep) db.session.commit() assert not has_timed_out(jobstep, plan) jobstep.date_started = datetime.utcnow() - timedelta(seconds=400) db.session.add(jobstep) db.session.commit() assert has_timed_out(jobstep, plan) option.value = '0' db.session.add(option) db.session.commit() assert not has_timed_out(jobstep, plan) option.value = '500' db.session.add(option) db.session.commit() assert not has_timed_out(jobstep, plan)
def test_single_phase(self): project = self.create_project() plan = self.create_plan() option = ItemOption( item_id=plan.id, name='build.expect-tests', value='0', ) db.session.add(option) db.session.commit() build = self.create_build(project=project) job = self.create_job(build=build) jobphase = self.create_jobphase( job=job, date_started=datetime(2013, 9, 19, 22, 15, 24), ) jobstep = self.create_jobstep(jobphase) jobstep2 = self.create_jobstep(jobphase) assert not is_missing_tests(plan, jobstep) option.value = '1' db.session.commit() assert is_missing_tests(plan, jobstep) testcase = TestCase( project_id=project.id, job_id=job.id, step_id=jobstep2.id, name='test', ) db.session.add(testcase) db.session.commit() assert is_missing_tests(plan, jobstep) testcase = TestCase( project_id=project.id, job_id=job.id, step_id=jobstep.id, name='test2', ) db.session.add(testcase) db.session.commit() assert not is_missing_tests(plan, jobstep)