def task_get(request, task=None): """Retrieve a task processing status for the given task id. :param request: A :class:`pyramid.request.Request` object. :type request: pyramid.request.Request :rtype: fanboi2.tasks.ResultProxy """ if task is None: task = celery.AsyncResult(request.matchdict['task']) response = ResultProxy(task) if response.success(): if isinstance(response.object, BaseError): raise response.object return response
def test_success_non_success(self): from fanboi2.tasks import ResultProxy proxy = ResultProxy(DummyAsyncResult('demo', 'pending')) self.assertFalse(proxy.success())
def test_success(self): from fanboi2.tasks import ResultProxy proxy = ResultProxy(DummyAsyncResult('demo', 'success')) self.assertTrue(proxy.success())