0

I want to do a unittest on a function inside Google App Engine taskqueue. I would like to know if there is any method by which we can execute the tasks in taskqueue so as to test whether it yields the desired output.

Jageet Mohan J
  • 115
  • 2
  • 9
  • can't you enqueue it to the queue and execute it from the queue? – marcadian Jun 09 '15 at 04:33
  • In my original code, countdown for taskqueue is 10 minutes. But I want to unittest the functionality I have written inside the task which. – Jageet Mohan J Jun 09 '15 at 10:54
  • 1
    does not matter the countdown, you can deque the task and just post to the url with the params https://cloud.google.com/appengine/docs/python/tools/localunittesting#Python_Writing_task_queue_tests http://googleappengine.googlecode.com/svn/trunk/python/google/appengine/api/taskqueue/taskqueue_stub.py – marcadian Jun 09 '15 at 17:50
  • Yes. Thats the best option available and testing post to url with params can be done by handler testing in Google App Engine [https://cloud.google.com/appengine/docs/python/tools/handlertesting](https://cloud.google.com/appengine/docs/python/tools/handlertesting). Can you please add your comment as the answer so that it can be useful for others too? @marcadian – Jageet Mohan J Jun 10 '15 at 18:20
  • done, posted as answer – marcadian Jun 10 '15 at 22:23

1 Answers1

3

You need to manually deque the task from the queue and post to the url with all the params. Check these doc https://cloud.google.com/appengine/docs/python/tools/localunittesting#Python_Writing_task_queue_tests http://googleappengine.googlecode.com/svn/trunk/python/google/appengine/api/taskqueue/taskqueue_stub.py

marcadian
  • 2,608
  • 13
  • 20
  • The TaskQueueServiceStub constructor has a param auto_task_running which suggests there could be a way to have the tasks executed by the stub as they are queued, but I have not been successful in using it. http://gae-pydoc.appspot.com/google.appengine.api.taskqueue.taskqueue_stub.TaskQueueServiceStub – TTimo Feb 09 '17 at 20:33
  • See http://stackoverflow.com/questions/6632809/gae-unit-testing-taskqueue-with-testbed for an example of how to manually execute the tasks. – TTimo Feb 09 '17 at 20:38