def pop_questionemailjobs(): jobs = sorted(QuestionEmailJob.iterReady(), key=lambda job: job.metadata["recipient_set"]) for job in jobs: job.start() job.complete() return jobs
def pop_questionemailjobs(): jobs = sorted( QuestionEmailJob.iterReady(), key=lambda job: job.metadata["recipient_set"]) for job in jobs: job.start() job.complete() return jobs
def test_iterReady(self): # Jobs in the ready state are returned by the iterator. # Creating a question implicitly created an question email job. asker = self.factory.makePerson() product = self.factory.makeProduct() naked_question_set = removeSecurityProxy(getUtility(IQuestionSet)) question = naked_question_set.new( title='title', description='description', owner=asker, language=getUtility(ILanguageSet)['en'], product=product, distribution=None, sourcepackagename=None) job_1 = make_question_job(self.factory, question=question, body='one') job_2 = make_question_job(self.factory, question=question, body='two') job_3 = make_question_job( self.factory, question=question, body='three') job_1.start() job_1.complete() job_ids = [job.id for job in QuestionEmailJob.iterReady()] self.assertContentEqual([job_2.id, job_3.id], job_ids)
def test_iterReady(self): # Jobs in the ready state are returned by the iterator. # Creating a question implicitly created an question email job. asker = self.factory.makePerson() product = self.factory.makeProduct() naked_question_set = removeSecurityProxy(getUtility(IQuestionSet)) question = naked_question_set.new( title='title', description='description', owner=asker, language=getUtility(ILanguageSet)['en'], product=product, distribution=None, sourcepackagename=None) job_1 = make_question_job(self.factory, question=question, body='one') job_2 = make_question_job(self.factory, question=question, body='two') job_3 = make_question_job(self.factory, question=question, body='three') job_1.start() job_1.complete() job_ids = [job.id for job in QuestionEmailJob.iterReady()] self.assertContentEqual([job_2.id, job_3.id], job_ids)