def test_taskhandler_08(self, ttl, result): """test ttl.""" r = add4(2, 3) th = TaskHandler() task = th.get_next_task() th.handle_task(task) time.sleep(ttl) clean_queue() assert r.result == result
def test_taskhandler_06(self, delay, ready): """test delay.""" th = TaskHandler() r = mult2(2, 2) time.sleep(delay) task = th.get_next_task() if task: th.handle_task(task) assert r.ready is ready
def test_taskhandler_05(self, a, b, result, status, ready): """test error handling.""" r = add2(a, b) th = TaskHandler() task = th.get_next_task() th.handle_task(task) assert task.status == status assert r.status == status assert r.result == result assert r.ready is True
def test_taskhandler_07(self): """test retries.""" r = add3(2, 'c') th = TaskHandler() task = th.get_next_task() th.handle_task(task) assert r.status == WAITING # should be false because the task is rescheduled assert r.ready is False time.sleep(1) task = th.get_next_task() # should be None becaus schedule delay is 1 sec. assert task is None time.sleep(1.5) task = th.get_next_task() assert task is not None th.handle_task(task) # now status should be ERROR and task is done assert r.status == ERROR assert r.ready is True