def test_add_done_callback(self): response = Simple(field1='foo', field2='bar') operation_future = self._make_operation_future( self._make_operation(), self._make_operation(done=True, response=response)) operation_future.test_queue = mp.Queue() operation_future.add_done_callback(_task1) operation_future.add_done_callback(_task2) self.assertEqual('foo', operation_future.test_queue.get()) self.assertEqual('bar', operation_future.test_queue.get())
def _Simple(value, other_value=None): if other_value is None: return Simple(field1=value) else: return Simple(field1=value, field2=other_value)
def test_result_response(self): response = Simple() operation = self._make_operation(done=True, response=response) operation_future = self._make_operation_future(operation) self.assertEqual(response, operation_future.result())
def test_exception_response(self): operation = self._make_operation(done=True, response=Simple()) operation_future = self._make_operation_future(operation) self.assertIsNone(operation_future.exception())
def test_metadata(self): metadata = Simple() operation = self._make_operation(metadata=metadata) operation_future = self._make_operation_future(operation) self.assertEqual(metadata, operation_future.metadata())