def test_cancel_beam_job_which_has_no_dataflow_job_id_raises_an_error( self) -> None: model = beam_job_services.create_beam_job_run_model( 'NoOpJob', dataflow_job_id=None) model.put() with self.swap_to_always_return(jobs_manager, 'cancel_job'): self.assertRaisesRegex( # type: ignore[no-untyped-call] ValueError, 'cannot be cancelled', lambda: beam_job_services.cancel_beam_job(model.id))
def test_cancel_beam_job(self) -> None: model = beam_job_services.create_beam_job_run_model( 'NoOpJob', dataflow_job_id='123') model.put() with self.swap_to_always_return(jobs_manager, 'cancel_job'): run = beam_job_services.cancel_beam_job(model.id) self.assertEqual( run.to_dict(), beam_job_services.get_beam_job_run_from_model(model).to_dict())
def delete(self) -> None: job_id = self.request.get('job_id') beam_job_run = beam_job_services.cancel_beam_job(job_id) self.render_json(beam_job_run.to_dict())
def test_cancel_beam_job_which_does_not_exist_raises_an_error( self) -> None: with self.swap_to_always_return(jobs_manager, 'cancel_job'): self.assertRaisesRegex( # type: ignore[no-untyped-call] ValueError, 'No such job', lambda: beam_job_services.cancel_beam_job('123'))
def delete(self) -> None: job_id = self.normalized_payload.get('job_id') beam_job_run = beam_job_services.cancel_beam_job(job_id) self.render_json(beam_job_run.to_dict())