def test_mark_as_done(self): cb = CacheBackend() tid = gen_unique_id() self.assertEqual(cb.get_status(tid), states.PENDING) self.assertIsNone(cb.get_result(tid)) cb.mark_as_done(tid, 42) self.assertEqual(cb.get_status(tid), states.SUCCESS) self.assertEqual(cb.get_result(tid), 42) self.assertTrue(cb.get_result(tid), 42)
def test_mark_as_done(self): cb = CacheBackend(app=app) tid = gen_unique_id() self.assertEqual(cb.get_status(tid), states.PENDING) self.assertIsNone(cb.get_result(tid)) cb.mark_as_done(tid, 42) self.assertEqual(cb.get_status(tid), states.SUCCESS) self.assertEqual(cb.get_result(tid), 42) self.assertTrue(cb.get_result(tid), 42)
def test_mark_as_failure(self): cb = CacheBackend(app=app) einfo = None tid3 = gen_unique_id() try: raise KeyError('foo') except KeyError as exception: einfo = ExceptionInfo(sys.exc_info()) cb.mark_as_failure(tid3, exception, traceback=einfo.traceback) self.assertEqual(cb.get_status(tid3), states.FAILURE) self.assertIsInstance(cb.get_result(tid3), KeyError) self.assertEqual(cb.get_traceback(tid3), einfo.traceback)
def test_mark_as_failure(self): cb = CacheBackend(app=app) einfo = None tid3 = gen_unique_id() try: raise KeyError('foo') except KeyError as exception: einfo = ExceptionInfo(sys.exc_info()) cb.mark_as_failure(tid3, exception, traceback=einfo.traceback) self.assertEqual(cb.get_status(tid3), states.FAILURE) self.assertIsInstance(cb.get_result(tid3), KeyError) self.assertEqual(cb.get_traceback(tid3), einfo.traceback)