def test_decision_event(self): helper = HistoryHelper(self.events) self.assertTrue(helper.has_next()) expected_decisions = [ ([ EventType.WorkflowExecutionStarted, EventType.DecisionTaskScheduled ], [EventType.ActivityTaskScheduled]), ([ EventType.ActivityTaskStarted, EventType.ActivityTaskCompleted, EventType.DecisionTaskScheduled ], [EventType.ActivityTaskScheduled]), ([ EventType.ActivityTaskStarted, EventType.ActivityTaskCompleted, EventType.DecisionTaskScheduled ], []), ] for expected_events, expected_decision_events in expected_decisions: e = helper.next() self.assertEqual(expected_events, list(map(lambda x: x.event_type, e.events))) self.assertEqual( expected_decision_events, list(map(lambda x: x.event_type, e.decision_events)))
def test_next_decision_event_id(self): helper = HistoryHelper(self.events) e = helper.next() self.assertEqual(5, e.next_decision_event_id) e = helper.next() self.assertEqual(11, e.next_decision_event_id) e = helper.next() self.assertEqual(17, e.next_decision_event_id)
def test_replay(self): helper = HistoryHelper(self.events) e = helper.next() self.assertTrue(e.replay) e = helper.next() self.assertTrue(e.replay) e = helper.next() self.assertFalse(e.replay)
def setUp(self) -> None: events = make_history([ EventType.WorkflowExecutionStarted, EventType.DecisionTaskScheduled, EventType.DecisionTaskStarted]) events[0].workflow_execution_started_event_attributes = WorkflowExecutionStartedEventAttributes() helper = HistoryHelper(events) self.decision_events = helper.next() worker: Worker = Mock() worker.get_workflow_method = MagicMock(return_value=(DummyWorkflow, lambda *args: None)) self.decider = ReplayDecider(execution_id="", workflow_type=Mock(), worker=worker) self.decider.event_loop = Mock()
def test_has_next(self): helper = HistoryHelper(self.events) self.assertTrue(helper.has_next()) helper.next() self.assertTrue(helper.has_next()) helper.next() self.assertTrue(helper.has_next()) helper.next() self.assertFalse(helper.has_next())