def test_is_job_completed(self): job_id = engine._job_from_file(helpers.get_data_path(CONFIG_FILE), "db").job_id row = OqCalculation.objects.get(id=job_id) pairs = [("pending", False), ("running", False), ("succeeded", True), ("failed", True)] for status, is_completed in pairs: row.status = status row.save() self.assertEqual(CalculationProxy.is_job_completed(job_id), is_completed)
def test_is_job_completed(self): job_id = engine._job_from_file( helpers.get_data_path(CONFIG_FILE), 'db').job_id row = models.OqJob.objects.get(id=job_id) pairs = [('pending', False), ('running', False), ('succeeded', True), ('failed', True)] for status, is_completed in pairs: row.status = status row.save() self.assertEqual( JobContext.is_job_completed(job_id), is_completed)
def test_get_status_from_db(self): self.job = engine._job_from_file(helpers.get_data_path(CONFIG_FILE), "db") row = OqCalculation.objects.get(id=self.job.job_id) row.status = "failed" row.save() self.assertEqual("failed", CalculationProxy.get_status_from_db(self.job.job_id)) row.status = "running" row.save() self.assertEqual("running", CalculationProxy.get_status_from_db(self.job.job_id))
def test_get_status_from_db(self): self.job = engine._job_from_file(helpers.get_data_path(CONFIG_FILE), "db") row = models.OqJob.objects.get(id=self.job.job_id) row.status = "failed" row.save() self.assertEqual("failed", JobContext.get_status_from_db(self.job.job_id)) row.status = "running" row.save() self.assertEqual("running", JobContext.get_status_from_db(self.job.job_id))
def job_from_file(config_file_path): """ Create a JobContext instance from the given configuration file. The results are configured to go to XML files. *No* database record will be stored for the job. This allows running test on jobs without requiring a database. """ job = engine._job_from_file(config_file_path, 'xml') cleanup_loggers() return job
def test_get_status_from_db(self): self.job = engine._job_from_file( helpers.get_data_path(CONFIG_FILE), 'db') row = models.OqJob.objects.get(id=self.job.job_id) row.status = "failed" row.save() self.assertEqual( "failed", JobContext.get_status_from_db(self.job.job_id)) row.status = "running" row.save() self.assertEqual( "running", JobContext.get_status_from_db(self.job.job_id))
def test_job_db_record_for_output_type_xml(self): self.job = engine._job_from_file( helpers.get_data_path(CONFIG_FILE), 'xml') models.OqJob.objects.get(id=self.job.job_id)
def test_job_db_record_for_output_type_xml(self): self.job = engine._job_from_file(helpers.get_data_path(CONFIG_FILE), "xml") OqCalculation.objects.get(id=self.job.job_id)