Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
            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
Ejemplo n.º 3
0
            def testParentUsesName2(self, taskqueue):
                main = task(noop)
                sub = task(P)
                main.enqueue_subtask(sub)
                main.enqueue_subtask(sub)

                assert count_tasks(taskqueue) == 1
Ejemplo n.º 4
0
            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
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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
Ejemplo n.º 7
0
        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
Ejemplo n.º 8
0
 def testDeferredHandler(self, taskqueue, ndb):
     task(Ok).success(task(handler)).run()
     assert count_tasks(taskqueue) == 1
     consume(taskqueue)
     assert ['Ok'] == messages
Ejemplo n.º 9
0
 def testIdCanBeReusedImmediately(self, taskqueue, ndb):
     task(noop).enqueue()
     assert count_tasks(taskqueue) == 1
     consume(taskqueue)
     task(noop).enqueue()
     assert count_tasks(taskqueue) == 1
Ejemplo n.º 10
0
 def testProtectedByGivenId2(self, taskqueue, ndb):
     task(noop, _use_id='A').enqueue()
     task(noop, _use_id='A').enqueue()
     assert count_tasks(taskqueue) == 1
Ejemplo n.º 11
0
 def testSilentlyDisallowDoubleExecution(self, taskqueue, ndb):
     task(noop).enqueue()
     task(noop).enqueue()
     assert count_tasks(taskqueue) == 1
Ejemplo n.º 12
0
 def testPreventNamedTaskToBeScheduledTwice2(self, taskqueue):
     task(noop, _name='A').enqueue()
     task(noop, _name='A').enqueue()
     assert count_tasks(taskqueue) == 1
Ejemplo n.º 13
0
 def testDisableProtection3(self, taskqueue):
     task(noop, _use_id=False).enqueue()
     task(noop, _use_id=False).enqueue()
     assert count_tasks(taskqueue) == 2
Ejemplo n.º 14
0
 def testGeneratedIdHandlesParameters2(self, taskqueue, ndb):
     task(P, message='ONE').enqueue()
     task(P, message='TWO').enqueue()
     assert count_tasks(taskqueue) == 2