def test_trivial(self): delegate = LoggingDelegate(self) work_queue = QueueEngine("trivial-queue", delegate) work_queue.run() self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks) self.assertTrue(os.path.exists(os.path.join(self.temp_dir, "queue_log_path"))) self.assertTrue(os.path.exists(os.path.join(self.temp_dir, "work_log_path", "work_item.log")))
def test_unexpected_error(self): delegate = ThrowErrorDelegate(self, 3) work_queue = QueueEngine("error-queue", delegate) work_queue.run() expected_callbacks = LoggingDelegate.expected_callbacks[:] work_item_index = expected_callbacks.index('process_work_item') # The unexpected error should be handled right after process_work_item starts # but before any other callback. Otherwise callbacks should be normal. expected_callbacks.insert(work_item_index + 1, 'handle_unexpected_error') self.assertEquals(delegate._callbacks, expected_callbacks)
def test_handled_error(self): delegate = ThrowErrorDelegate(self, QueueEngine.handled_error_code) work_queue = QueueEngine("handled-error-queue", delegate) work_queue.run() self.assertEquals(delegate._callbacks, LoggingDelegate.expected_callbacks)