def test_complete(self): """Job.complete should update the Job appropriately. It should set date_finished and set the job status to COMPLETED. """ job = Job(_status=JobStatus.RUNNING) self.assertEqual(None, job.date_finished) job.complete() self.assertNotEqual(None, job.date_finished) self.assertEqual(job.status, JobStatus.COMPLETED)
def test_complete_manages_transactions(self): # Job.complete() does not commit the transaction by default. job = Job() job.start() with TransactionRecorder() as recorder: job.complete() self.assertEqual([], recorder.transaction_calls) # If explicitly specified, Job.complete() commits the transaction. job = Job() job.start() with TransactionRecorder() as recorder: job.complete(manage_transaction=True) self.assertEqual(['commit', 'commit'], recorder.transaction_calls)