def on_get(self, req, resp, tenant_id, job_id, run_number): job_execution = JobExecution.get_job(run_number) JobExecution.save_job(job_execution) if job_execution: resp.body = self.format_response_body(job_execution.as_dict()) else: msg = 'Cannot find run number: {id}'.format(id=run_number) resp.status = falcon.HTTP_404 resp.body = json.dumps({'description': msg})
def on_head(self, req, resp, tenant_id, job_id): job = Job.get_job(job_id) job_ex = JobExecution.build_job_from_dict(job.as_dict()) if job: # TODO(jmv): Figure out scheduling of jobs JobExecution.save_job(job_ex) job.run_numbers.append(job_ex.run_number) Job.update_job(job) job = Job.get_job(job_id) execute_job.delay(job.id) resp.status = falcon.HTTP_200 else: msg = 'Cannot find job: {job_id}'.format(job_id=job_id) resp.status = falcon.HTTP_404 resp.body = json.dumps({'description': msg})
def can_save(self): JobExecution.save_job(self.job_ex, handler=self.handler) expect(len(self.handler.insert_document.calls)).to.equal(1)