def testB(self, taskqueue, ndb): A = task(CACHED).enqueue(name='A') B = task(CACHED).enqueue(name='B') assert count_tasks(taskqueue) == 2 tick(taskqueue) assert count_tasks(taskqueue) == 2 tick(taskqueue) assert count_tasks(taskqueue) == 0 assert 'ONCE ONCE'.split() == messages
def testA(self, taskqueue, ndb): A = queue.inorder( task(P) ).enqueue(use_id='A') B = queue.inorder( task(P) ).enqueue(use_id='B') assert count_tasks(taskqueue) == 2 tick(taskqueue) assert count_tasks(taskqueue) == 2 tick(taskqueue) assert count_tasks(taskqueue) == 0 assert 'P P'.split() == messages
def testParentUsesName2(self, taskqueue): main = task(noop) sub = task(P) main.enqueue_subtask(sub) main.enqueue_subtask(sub) assert count_tasks(taskqueue) == 1
def testParentUsesId2(self, taskqueue): main = task(noop, _use_id='A') sub = task(P) main.enqueue_subtask(sub) main.enqueue_subtask(sub) assert count_tasks(taskqueue) == 1
def testParallel(self, taskqueue, ndb): queue.parallel( task(P, 'ONE'), task(P, 'TWO'), task(P, 'THREE') ).run() assert count_tasks(taskqueue) == 3 consume(taskqueue) assert 'ONE TWO THREE'.split() == messages
def testInOrder(self, taskqueue, ndb): queue.inorder( task(A), task(B), task(C) ).run() assert count_tasks(taskqueue) == 1 consume(taskqueue) assert ['A', 'B', 'C'] == messages
def testIdIsReleasedAfterXSeconds(self, taskqueue, ndb): task(noop).enqueue(release_after=1) assert count_tasks(taskqueue) == 1 tick(taskqueue) assert count_tasks(taskqueue) == 1 # the cleanup handler cleanup_handler = taskqueue.get_filtered_tasks()[0] now = datetime.datetime.now(tz=queue.taskqueue.taskqueue._UTC) now = now.replace(microsecond=0) assert cleanup_handler.eta == now + datetime.timedelta(seconds=1) task(noop).enqueue() assert count_tasks(taskqueue) == 1 tick(taskqueue) assert count_tasks(taskqueue) == 0 # ensure task(noop).enqueue() assert count_tasks(taskqueue) == 1
def testDeferredHandler(self, taskqueue, ndb): task(Ok).success(task(handler)).run() assert count_tasks(taskqueue) == 1 consume(taskqueue) assert ['Ok'] == messages
def testIdCanBeReusedImmediately(self, taskqueue, ndb): task(noop).enqueue() assert count_tasks(taskqueue) == 1 consume(taskqueue) task(noop).enqueue() assert count_tasks(taskqueue) == 1
def testProtectedByGivenId2(self, taskqueue, ndb): task(noop, _use_id='A').enqueue() task(noop, _use_id='A').enqueue() assert count_tasks(taskqueue) == 1
def testSilentlyDisallowDoubleExecution(self, taskqueue, ndb): task(noop).enqueue() task(noop).enqueue() assert count_tasks(taskqueue) == 1
def testPreventNamedTaskToBeScheduledTwice2(self, taskqueue): task(noop, _name='A').enqueue() task(noop, _name='A').enqueue() assert count_tasks(taskqueue) == 1
def testDisableProtection3(self, taskqueue): task(noop, _use_id=False).enqueue() task(noop, _use_id=False).enqueue() assert count_tasks(taskqueue) == 2
def testGeneratedIdHandlesParameters2(self, taskqueue, ndb): task(P, message='ONE').enqueue() task(P, message='TWO').enqueue() assert count_tasks(taskqueue) == 2