def test_job_subcommand(self): """Test the job subcommand for updating job state.""" rwfd, fname = mkstemp() os.close(rwfd) with test_database(SqliteDatabase(fname), (BaseModel, IngestState)): IngestState.create(job_id=999, state='ERROR', task='unbundling', task_percent=42.3) IngestState.database_close() cmd([ 'job', '--task=unbundling', '--job-id=999', '--state=OK', '--task-percent=100.0', '--exception=Badness' ]) record = read_state(999) self.assertEqual(record.state, 'OK') self.assertEqual(record.task_percent, 100.0)
def test_update_state(self): """Test return and update of unique index.""" return with test_database(TEST_DB, (BaseModel, IngestState)): test_object = IngestState.create(job_id=999, state='ERROR', task='unbundling', task_percent=42.3) self.assertEqual(test_object.job_id, 999) update_state(999, 'WORKING', 'validating', 33.2) record = read_state(999) self.assertEqual(record.state, 'WORKING') self.assertEqual(record.task, 'validating')
def test_update_state(self): """Test return and update of unique index.""" with test_database(TEST_DB, (BaseModel, IngestState)): test_object = IngestState.create(job_id=999, state='ERROR', task='unbundling', task_percent=42.3) self.assertEqual(test_object.job_id, 999) IngestState.database_close() update_state(999, 'WORKING', 'validating', 33.2) record = read_state(999) self.assertEqual(record.state, 'WORKING') self.assertEqual(record.task, 'validating') self.assertEqual(float(record.task_percent), 33.2) record = read_state(None) self.assertEqual(record.state, 'DATA_ACCESS_ERROR') self.assertEqual(record.task, 'read_state') self.assertEqual(record.task_percent, 0)