def setUp(self): self.domain = Domain("TestDomain") self.wt = WorkflowType(self.domain, "TestType", "1.0") self.we = WorkflowExecution( self.domain, self.wt, "TestType-0.1-TestDomain" )
def test_instantiation(self): we = WorkflowExecution(self.domain, self.wt, "TestType-0.1-TestDomain") self.assertIsNotNone(we) self.assertIsInstance(we, WorkflowExecution) self.assertIn( we.status, [WorkflowExecution.STATUS_OPEN, WorkflowExecution.STATUS_CLOSED] )
def test_workflow_execution_changes_with_identical_workflow_execution( self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked['executionInfo']['execution']['workflowId'], run_id=mocked['executionInfo']['execution']['runId'], status=mocked['executionInfo']['executionStatus'], task_list=mocked['executionConfiguration']['taskList']['name'], child_policy=mocked['executionConfiguration']['childPolicy'], execution_timeout=mocked['executionConfiguration'] ['executionStartToCloseTimeout'], tag_list=mocked['executionInfo']['tagList'], decision_tasks_timeout=mocked['executionConfiguration'] ['taskStartToCloseTimeout'], ) diffs = workflow_execution.changes self.assertEqual(len(diffs), 0)
def test___diff_with_different_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id", ) diffs = workflow_execution._diff() self.assertIsNotNone(diffs) self.assertLength(diffs, 7) self.assertTrue(hasattr(diffs[0], "attr")) self.assertTrue(hasattr(diffs[0], "local")) self.assertTrue(hasattr(diffs[0], "upstream"))
def test_is_synced_over_non_existent_workflow_execution(self): with patch.object(Layer1, 'describe_workflow_execution', mock_describe_workflow_execution): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id") self.assertFalse(workflow_execution.is_synced)
def test___diff_with_different_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id") diffs = workflow_execution._diff() self.assertIsNotNone(diffs) self.assertEqual(len(diffs), 7) self.assertTrue(hasattr(diffs[0], 'attr')) self.assertTrue(hasattr(diffs[0], 'local')) self.assertTrue(hasattr(diffs[0], 'upstream'))
def test___diff_with_different_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id" ) diffs = workflow_execution._diff() self.assertIsNotNone(diffs) self.assertEqual(len(diffs), 7) self.assertTrue(hasattr(diffs[0], 'attr')) self.assertTrue(hasattr(diffs[0], 'local')) self.assertTrue(hasattr(diffs[0], 'upstream'))
def test_workflow_execution__diff_with_identical_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked['executionInfo']['execution']['workflowId'], run_id=mocked['executionInfo']['execution']['runId'], status=mocked['executionInfo']['executionStatus'], task_list=mocked['executionConfiguration']['taskList']['name'], child_policy=mocked['executionConfiguration']['childPolicy'], execution_timeout=mocked['executionConfiguration']['executionStartToCloseTimeout'], tag_list=mocked['executionInfo']['tagList'], decision_tasks_timeout=mocked['executionConfiguration']['taskStartToCloseTimeout'], ) diffs = workflow_execution._diff() self.assertEqual(len(diffs), 0)
def test_workflow_execution__diff_with_identical_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked["executionInfo"]["execution"]["workflowId"], run_id=mocked["executionInfo"]["execution"]["runId"], status=mocked["executionInfo"]["executionStatus"], task_list=mocked["executionConfiguration"]["taskList"]["name"], child_policy=mocked["executionConfiguration"]["childPolicy"], execution_timeout=mocked["executionConfiguration"][ "executionStartToCloseTimeout" ], tag_list=mocked["executionInfo"]["tagList"], decision_tasks_timeout=mocked["executionConfiguration"][ "taskStartToCloseTimeout" ], ) diffs = workflow_execution._diff() self.assertLength(diffs, 0)
def to_WorkflowExecution(self, domain, execution_info, **kwargs): workflow_type = WorkflowType( self.domain, execution_info['workflowType']['name'], execution_info['workflowType']['version'] ) return WorkflowExecution( domain, get_subkey(execution_info, ['execution', 'workflowId']), # workflow_id run_id=get_subkey(execution_info, ['execution', 'runId']), workflow_type=workflow_type, status=execution_info.get('executionStatus'), close_status=execution_info.get('closeStatus'), tag_list=execution_info.get('tagList'), **kwargs )
def to_WorkflowExecution(self, domain, execution_info, **kwargs): workflow_type = WorkflowType(self.domain, execution_info['workflowType']['name'], execution_info['workflowType']['version']) return WorkflowExecution( domain, get_subkey(execution_info, ['execution', 'workflowId']), # workflow_id run_id=get_subkey(execution_info, ['execution', 'runId']), workflow_type=workflow_type, status=execution_info.get('executionStatus'), close_status=execution_info.get('closeStatus'), tag_list=execution_info.get('tagList'), start_timestamp=execution_info.get('startTimestamp'), close_timestamp=execution_info.get('closeTimestamp'), cancel_requested=execution_info.get('cancelRequested'), parent=execution_info.get('parent'), **kwargs)
def to_WorkflowExecution(self, domain, execution_info, **kwargs): workflow_type = WorkflowType( self.domain, execution_info["workflowType"]["name"], execution_info["workflowType"]["version"], ) return WorkflowExecution( domain, get_subkey(execution_info, ["execution", "workflowId"]), # workflow_id run_id=get_subkey(execution_info, ["execution", "runId"]), workflow_type=workflow_type, status=execution_info.get("executionStatus"), close_status=execution_info.get("closeStatus"), tag_list=execution_info.get("tagList"), start_timestamp=execution_info.get("startTimestamp"), close_timestamp=execution_info.get("closeTimestamp"), cancel_requested=execution_info.get("cancelRequested"), parent=execution_info.get("parent"), **kwargs )
class TestWorkflowExecution(unittest.TestCase, CustomAssertions): def setUp(self): self.domain = Domain("TestDomain") self.wt = WorkflowType(self.domain, "TestType", "1.0") self.we = WorkflowExecution(self.domain, self.wt, "TestType-0.1-TestDomain") def tearDown(self): pass def test_instantiation(self): we = WorkflowExecution(self.domain, self.wt, "TestType-0.1-TestDomain") self.assertIsNotNone(we) self.assertIsInstance(we, WorkflowExecution) self.assertIn( we.status, [WorkflowExecution.STATUS_OPEN, WorkflowExecution.STATUS_CLOSED] ) def test___diff_with_different_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id", ) diffs = workflow_execution._diff() self.assertIsNotNone(diffs) self.assertLength(diffs, 7) self.assertTrue(hasattr(diffs[0], "attr")) self.assertTrue(hasattr(diffs[0], "local")) self.assertTrue(hasattr(diffs[0], "upstream")) def test_workflow_execution__diff_with_identical_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked["executionInfo"]["execution"]["workflowId"], run_id=mocked["executionInfo"]["execution"]["runId"], status=mocked["executionInfo"]["executionStatus"], task_list=mocked["executionConfiguration"]["taskList"]["name"], child_policy=mocked["executionConfiguration"]["childPolicy"], execution_timeout=mocked["executionConfiguration"][ "executionStartToCloseTimeout" ], tag_list=mocked["executionInfo"]["tagList"], decision_tasks_timeout=mocked["executionConfiguration"][ "taskStartToCloseTimeout" ], ) diffs = workflow_execution._diff() self.assertLength(diffs, 0) def test_exists_with_existing_workflow_execution(self): with patch.object(Layer1, "describe_workflow_execution"): self.assertTrue(self.we.exists) def test_exists_with_non_existent_workflow_execution(self): with patch.object(self.we.connection, "describe_workflow_execution") as mock: mock.side_effect = SWFResponseError( 400, "Bad Request:", { "__type": "com.amazonaws.swf.base.model#UnknownResourceFault", "message": "Unknown execution: WorkflowExecution=[workflowId=blah, runId=test]", }, "UnknownResourceFault", ) self.assertFalse(self.we.exists) # TODO: fix test when no network (probably hits real SWF endpoints) @unittest.skip("Skip it in case there's no network connection.") def test_workflow_execution_exists_with_whatever_error(self): with patch.object(self.we.connection, "describe_workflow_execution") as mock: with self.assertRaises(ResponseError): mock.side_effect = SWFResponseError( 400, "mocking exception", {"__type": "WhateverError", "message": "Whatever"}, ) dummy = self.domain.exists def test_is_synced_with_unsynced_workflow_execution(self): pass def test_is_synced_with_synced_workflow_execution(self): pass def test_is_synced_over_non_existent_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id", ) self.assertFalse(workflow_execution.is_synced) def test_changes_with_different_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id", ) diffs = workflow_execution.changes self.assertIsNotNone(diffs) self.assertLength(diffs, 7) self.assertTrue(hasattr(diffs[0], "attr")) self.assertTrue(hasattr(diffs[0], "local")) self.assertTrue(hasattr(diffs[0], "upstream")) def test_workflow_execution_changes_with_identical_workflow_execution(self): with patch.object( Layer1, "describe_workflow_execution", mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked["executionInfo"]["execution"]["workflowId"], run_id=mocked["executionInfo"]["execution"]["runId"], status=mocked["executionInfo"]["executionStatus"], task_list=mocked["executionConfiguration"]["taskList"]["name"], child_policy=mocked["executionConfiguration"]["childPolicy"], execution_timeout=mocked["executionConfiguration"][ "executionStartToCloseTimeout" ], tag_list=mocked["executionInfo"]["tagList"], decision_tasks_timeout=mocked["executionConfiguration"][ "taskStartToCloseTimeout" ], ) diffs = workflow_execution.changes self.assertLength(diffs, 0) def test_history(self): with patch.object( self.we.connection, "get_workflow_execution_history", mock_get_workflow_execution_history, ): history = self.we.history() self.assertIsInstance(history, History)
def poll(self, task_list=None, identity=None, **kwargs): """ Polls a decision task and returns the token and the full history of the workflow's events. :param task_list: task list to poll for decision tasks from. :type task_list: str :param identity: Identity of the decider making the request, which is recorded in the DecisionTaskStarted event in the workflow history. :type identity: str :returns: a Response object with history, token, and execution set :rtype: swf.responses.Response """ task_list = task_list or self.task_list task = self.connection.poll_for_decision_task(self.domain.name, task_list=task_list, identity=identity, **kwargs) token = task.get('taskToken') if token is None: raise PollTimeout("Decider poll timed out") events = task['events'] next_page = task.get('nextPageToken') while next_page: try: task = self.connection.poll_for_decision_task( self.domain.name, task_list=task_list, identity=identity, next_page_token=next_page, **kwargs) except boto.exception.SWFResponseError as e: if e.error_code == 'UnknownResourceFault': raise DoesNotExistError( "Unable to poll decision task", e.body['message'], ) raise ResponseError(e.body['message']) token = task.get('taskToken') if token is None: raise PollTimeout("Decider poll timed out") events.extend(task['events']) next_page = task.get('nextPageToken') history = History.from_event_list(events) workflow_type = WorkflowType( domain=self.domain, name=task['workflowType']['name'], version=task['workflowType']['version'], ) execution = WorkflowExecution( domain=self.domain, workflow_id=task['workflowExecution']['workflowId'], run_id=task['workflowExecution']['runId'], workflow_type=workflow_type, ) # TODO: move history into execution (needs refactoring on WorkflowExecution.history()) return Response(token=token, history=history, execution=execution)
class TestWorkflowExecution(unittest2.TestCase): def setUp(self): self.domain = Domain("TestDomain") self.wt = WorkflowType(self.domain, "TestType", "1.0") self.we = WorkflowExecution( self.domain, self.wt, "TestType-0.1-TestDomain" ) def tearDown(self): pass def test_instantiation(self): we = WorkflowExecution( self.domain, self.wt, "TestType-0.1-TestDomain" ) self.assertIsNotNone(we) self.assertIsInstance(we, WorkflowExecution) self.assertIn(we.status, [ WorkflowExecution.STATUS_OPEN, WorkflowExecution.STATUS_CLOSED ]) def test___diff_with_different_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id" ) diffs = workflow_execution._diff() self.assertIsNotNone(diffs) self.assertEqual(len(diffs), 7) self.assertTrue(hasattr(diffs[0], 'attr')) self.assertTrue(hasattr(diffs[0], 'local')) self.assertTrue(hasattr(diffs[0], 'upstream')) def test_workflow_execution__diff_with_identical_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked['executionInfo']['execution']['workflowId'], run_id=mocked['executionInfo']['execution']['runId'], status=mocked['executionInfo']['executionStatus'], task_list=mocked['executionConfiguration']['taskList']['name'], child_policy=mocked['executionConfiguration']['childPolicy'], execution_timeout=mocked['executionConfiguration']['executionStartToCloseTimeout'], tag_list=mocked['executionInfo']['tagList'], decision_tasks_timeout=mocked['executionConfiguration']['taskStartToCloseTimeout'], ) diffs = workflow_execution._diff() self.assertEqual(len(diffs), 0) def test_exists_with_existing_workflow_execution(self): with patch.object(Layer1, 'describe_workflow_execution'): self.assertTrue(self.we.exists) def test_exists_with_non_existent_workflow_execution(self): with patch.object(self.we.connection, 'describe_workflow_execution') as mock: mock.side_effect = SWFResponseError( 400, "Bad Request:", {'__type': 'com.amazonaws.swf.base.model#UnknownResourceFault', 'message': 'Unknown execution: WorkflowExecution=[workflowId=blah, runId=test]'}, 'UnknownResourceFault', ) self.assertFalse(self.we.exists) def test_workflow_execution_exists_with_whatever_error(self): with patch.object(self.we.connection, 'describe_workflow_execution') as mock: with self.assertRaises(ResponseError): mock.side_effect = SWFResponseError( 400, "mocking exception", { '__type': 'WhateverError', 'message': 'Whatever' } ) self.domain.exists def test_is_synced_with_unsynced_workflow_execution(self): pass def test_is_synced_with_synced_workflow_execution(self): pass def test_is_synced_over_non_existent_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id" ) self.assertFalse(workflow_execution.is_synced) def test_changes_with_different_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id" ) diffs = workflow_execution.changes self.assertIsNotNone(diffs) self.assertEqual(len(diffs), 7) self.assertTrue(hasattr(diffs[0], 'attr')) self.assertTrue(hasattr(diffs[0], 'local')) self.assertTrue(hasattr(diffs[0], 'upstream')) def test_workflow_execution_changes_with_identical_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked['executionInfo']['execution']['workflowId'], run_id=mocked['executionInfo']['execution']['runId'], status=mocked['executionInfo']['executionStatus'], task_list=mocked['executionConfiguration']['taskList']['name'], child_policy=mocked['executionConfiguration']['childPolicy'], execution_timeout=mocked['executionConfiguration']['executionStartToCloseTimeout'], tag_list=mocked['executionInfo']['tagList'], decision_tasks_timeout=mocked['executionConfiguration']['taskStartToCloseTimeout'], ) diffs = workflow_execution.changes self.assertEqual(len(diffs), 0) def test_history(self): with patch.object( self.we.connection, 'get_workflow_execution_history', mock_get_workflow_execution_history ): history = self.we.history() self.assertIsInstance(history, History)
class TestWorkflowExecution(unittest.TestCase): def setUp(self): self.domain = Domain("TestDomain") self.wt = WorkflowType(self.domain, "TestType", "1.0") self.we = WorkflowExecution(self.domain, self.wt, "TestType-0.1-TestDomain") def tearDown(self): pass def test_instantiation(self): we = WorkflowExecution(self.domain, self.wt, "TestType-0.1-TestDomain") self.assertIsNotNone(we) self.assertIsInstance(we, WorkflowExecution) self.assertIn( we.status, [WorkflowExecution.STATUS_OPEN, WorkflowExecution.STATUS_CLOSED]) def test___diff_with_different_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id") diffs = workflow_execution._diff() self.assertIsNotNone(diffs) self.assertEqual(len(diffs), 7) self.assertTrue(hasattr(diffs[0], 'attr')) self.assertTrue(hasattr(diffs[0], 'local')) self.assertTrue(hasattr(diffs[0], 'upstream')) def test_workflow_execution__diff_with_identical_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked['executionInfo']['execution']['workflowId'], run_id=mocked['executionInfo']['execution']['runId'], status=mocked['executionInfo']['executionStatus'], task_list=mocked['executionConfiguration']['taskList']['name'], child_policy=mocked['executionConfiguration']['childPolicy'], execution_timeout=mocked['executionConfiguration'] ['executionStartToCloseTimeout'], tag_list=mocked['executionInfo']['tagList'], decision_tasks_timeout=mocked['executionConfiguration'] ['taskStartToCloseTimeout'], ) diffs = workflow_execution._diff() self.assertEqual(len(diffs), 0) def test_exists_with_existing_workflow_execution(self): with patch.object(Layer1, 'describe_workflow_execution'): self.assertTrue(self.we.exists) def test_exists_with_non_existent_workflow_execution(self): with patch.object(self.we.connection, 'describe_workflow_execution') as mock: mock.side_effect = SWFResponseError( 400, "Bad Request:", { '__type': 'com.amazonaws.swf.base.model#UnknownResourceFault', 'message': 'Unknown execution: WorkflowExecution=[workflowId=blah, runId=test]' }, 'UnknownResourceFault', ) self.assertFalse(self.we.exists) # TODO: fix test when no network (probably hits real SWF endpoints) @unittest.skip("Skip it in case there's no network connection.") def test_workflow_execution_exists_with_whatever_error(self): with patch.object(self.we.connection, 'describe_workflow_execution') as mock: with self.assertRaises(ResponseError): mock.side_effect = SWFResponseError(400, "mocking exception", { '__type': 'WhateverError', 'message': 'Whatever' }) self.domain.exists def test_is_synced_with_unsynced_workflow_execution(self): pass def test_is_synced_with_synced_workflow_execution(self): pass def test_is_synced_over_non_existent_workflow_execution(self): with patch.object(Layer1, 'describe_workflow_execution', mock_describe_workflow_execution): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id") self.assertFalse(workflow_execution.is_synced) def test_changes_with_different_workflow_execution(self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): workflow_execution = WorkflowExecution( self.domain, WorkflowType(self.domain, "NonExistentTestType", "1.0"), "non-existent-id") diffs = workflow_execution.changes self.assertIsNotNone(diffs) self.assertEqual(len(diffs), 7) self.assertTrue(hasattr(diffs[0], 'attr')) self.assertTrue(hasattr(diffs[0], 'local')) self.assertTrue(hasattr(diffs[0], 'upstream')) def test_workflow_execution_changes_with_identical_workflow_execution( self): with patch.object( Layer1, 'describe_workflow_execution', mock_describe_workflow_execution, ): mocked = mock_describe_workflow_execution() workflow_execution = WorkflowExecution( self.domain, mocked['executionInfo']['execution']['workflowId'], run_id=mocked['executionInfo']['execution']['runId'], status=mocked['executionInfo']['executionStatus'], task_list=mocked['executionConfiguration']['taskList']['name'], child_policy=mocked['executionConfiguration']['childPolicy'], execution_timeout=mocked['executionConfiguration'] ['executionStartToCloseTimeout'], tag_list=mocked['executionInfo']['tagList'], decision_tasks_timeout=mocked['executionConfiguration'] ['taskStartToCloseTimeout'], ) diffs = workflow_execution.changes self.assertEqual(len(diffs), 0) def test_history(self): with patch.object(self.we.connection, 'get_workflow_execution_history', mock_get_workflow_execution_history): history = self.we.history() self.assertIsInstance(history, History)
def poll(self, task_list=None, identity=None, **kwargs): """ Polls a decision task and returns the token and the full history of the workflow's events. :param task_list: task list to poll for decision tasks from. :type task_list: str :param identity: Identity of the decider making the request, which is recorded in the DecisionTaskStarted event in the workflow history. :type identity: str :returns: a Response object with history, token, and execution set :rtype: swf.responses.Response """ logging_context.reset() task_list = task_list or self.task_list task = self.connection.poll_for_decision_task( self.domain.name, task_list=task_list, identity=format.identity(identity), **kwargs) token = task.get("taskToken") if not token: raise PollTimeout("Decider poll timed out") events = task["events"] logging_context.set("workflow_id", task["workflowExecution"]["workflowId"]) logging_context.set("task_type", "decision") logging_context.set("event_id", task["startedEventId"]) next_page = task.get("nextPageToken") while next_page: try: task = self.connection.poll_for_decision_task( self.domain.name, task_list=task_list, identity=format.identity(identity), next_page_token=next_page, **kwargs) except boto.exception.SWFResponseError as e: message = self.get_error_message(e) if e.error_code == "UnknownResourceFault": raise DoesNotExistError( "Unable to poll decision task", message, ) raise ResponseError(message) token = task.get("taskToken") if not token: raise PollTimeout("Decider poll timed out") events.extend(task["events"]) next_page = task.get("nextPageToken") history = History.from_event_list(events) workflow_type = WorkflowType( domain=self.domain, name=task["workflowType"]["name"], version=task["workflowType"]["version"], ) execution = WorkflowExecution( domain=self.domain, workflow_id=task["workflowExecution"]["workflowId"], run_id=task["workflowExecution"]["runId"], workflow_type=workflow_type, ) # TODO: move history into execution (needs refactoring on WorkflowExecution.history()) return Response(token=token, history=history, execution=execution)