def test_iterReady(self): # The POFileStatsJob class provides a way to iterate over the jobs # that are ready to run. Initially, there aren't any. self.assertEqual(len(list(POFileStatsJob.iterReady())), 0) # We need a POFile to update. pofile = self.factory.makePOFile(side=TranslationSide.UPSTREAM) # If we schedule a job, then we'll get it back. job = pofilestatsjob.schedule(pofile.id) self.assertIs(list(POFileStatsJob.iterReady())[0], job)
def test_second_job_is_scheduled(self): # If there is already one POFileStatsJob scheduled for a particular # POFile, then a second one is scheduled. self.assertEqual(len(list(POFileStatsJob.iterReady())), 0) # We need a POFile to update. pofile = self.factory.makePOFile(side=TranslationSide.UPSTREAM) # If we schedule a job, then there will be one scheduled. pofilestatsjob.schedule(pofile.id) self.assertIs(len(list(POFileStatsJob.iterReady())), 1) # If we attempt to schedule another job for the same POFile, a new job # is added. pofilestatsjob.schedule(pofile.id) self.assertIs(len(list(POFileStatsJob.iterReady())), 2)
def test_job_interface(self): # Instances of POFileStatsJob are runnable jobs. verifyObject(IRunnableJob, POFileStatsJob(0))