def test_delayable(self): @task def foo(*args, **kwargs): # Assert that when it's called, it's beind delayed. assert kwargs['delivery_info']['is_eager'] add(foo, 1) process()
def index_addons(ids, **kw): # For the moment, only do this in the test suite. if settings.IN_TEST_SUITE: for pk in ids: add(index_addon_callback, pk) else: # We don't do a lot of multiple calls on requests, so let's just call # that normally. index_addon_callback(ids)
def test_add(self): add(self.callback, 1) eq_(len(_locals.tasks), 1) add(self.callback, 1) eq_(len(_locals.tasks), 1) add(self.callback, 2) eq_(len(_locals.tasks), 2) callback = mock.Mock() callback.__name__ = 'bar' add(callback, 2) eq_(len(_locals.tasks), 3)
def index_addon_held(ids, **kw): # Hold the indexes till the end of the request or until lib.es signal, # process is called. for pk in ids: add(index_addons, pk)
def test_request_finished(self): add(self.callback, 1) self.client.get('/') assert self.callback.called
def foo(): add(self.callback, 1)
def test_context(self): with context.send(): add(self.callback, 1) assert self.callback.called
def test_process_groups(self): add(self.callback, 1) add(self.callback, 4) process() eq_(set(self.callback.call_args[0][0]), set([1, 4]))
def test_process(self): add(self.callback, 1) process() assert self.callback.called
def test_reset(self): add(self.callback, 1) eq_(len(_locals.tasks), 1) reset() eq_(len(_locals.tasks), 0)