Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task queue works from view, but UnknownQueueError when run from unit tests

Updated: Originally I didn't realize this only fails when run from unit tests.

I have a working task queue in AppEngine with Python. - When calling a view manually, the task is added to the queue and runs - When called from unit tests, adding the task to the queue fails with an UnknownQueueError.

When reading about others who've encountered this issue, there have been some suggestions of overriding taskqueue_stub to fix this. But I'm not sure exactly how this should be done or why.

like image 428
mikemaccana Avatar asked Mar 16 '11 11:03

mikemaccana


1 Answers

Edit: working answer. My problem was adding the stub fix in an individual unit test: moving it to setUp() fixed things.

In tests.py

from google.appengine.api import apiproxy_stub_map
import os

class BlahTest(MyAppTestCase)
    def setUp(self):
        '''Ensure dev appserver task queue knows where to find queue.yaml'''
        taskqueue_stub = apiproxy_stub_map.apiproxy.GetStub( 'taskqueue' ) 
        dircontainingqueuedotyaml = os.path.dirname(os.path.dirname( __file__ ))
        taskqueue_stub._root_path = dircontainingqueuedotyaml

This now works.

like image 170
mikemaccana Avatar answered Oct 20 '22 14:10

mikemaccana