def test_clear_complete_keep(self): # Create complete, 'keep' task doc = TaskDoc.make(dict( task=dict(name='foo', args=[], kwargs={}), result_type='keep', state='complete')) doc.m.save() # timeout tasks TaskObject.clear_complete() # Make sure the doc is gone self.assertEqual(TaskDoc.m.find().count(), 1)
def test_timeout_tasks(self): # Create busy task doc = TaskDoc.make(dict( task=dict(name='foo',args=[],kwargs={}), time=dict(start=datetime.utcnow()), state='busy')) doc.m.save() # timeout tasks TaskObject.timeout_tasks( datetime.utcnow() + timedelta(seconds=10)) doc = TaskDoc.m.get() # Make sure the doc is ready and unlocked self.assertEqual(doc.state, 'ready') self.assertEqual(doc.process, None)