def test_handle_timer_started(decider, mock_decision: DecisionStateMachine):
    event = HistoryEvent()
    event.event_id = DECISION_EVENT_ID
    decider.handle_timer_started(event)
    mock_decision.handle_initiated_event.assert_called_once()
    args, kwargs = mock_decision.handle_initiated_event.call_args_list[0]
    assert args[0] is event
def test_handle_cancel_timer_failed(decider, mock_decision: DecisionStateMachine):
    event = HistoryEvent()
    event.event_id = DECISION_EVENT_ID
    ret = decider.handle_cancel_timer_failed(event)
    assert ret is True
    mock_decision.handle_cancellation_failure_event.assert_called_once()
    args, kwargs = mock_decision.handle_cancellation_failure_event.call_args_list[0]
    assert args[0] is event
Ejemplo n.º 3
0
def marker_recorded_event(marker_header_json):
    event = HistoryEvent()
    event.event_id = 20
    event.event_type = EventType.MarkerRecorded
    event.marker_recorded_event_attributes = MarkerRecordedEventAttributes()
    event.marker_recorded_event_attributes.marker_name = "the-marker-name"
    event.marker_recorded_event_attributes.header = Header()
    event.marker_recorded_event_attributes.header.fields[MUTABLE_MARKER_HEADER_KEY] = bytes(marker_header_json, "utf-8")
    event.marker_recorded_event_attributes.details = b'blah-blah'
    return event
Ejemplo n.º 4
0
def version_marker_recorded_event(marker_header_json):
    marker_header_json = MarkerHeader(id="abc", event_id=55, access_count=0).to_json()
    event = HistoryEvent()
    event.event_id = 20
    event.event_type = EventType.MarkerRecorded
    event.marker_recorded_event_attributes = MarkerRecordedEventAttributes()
    event.marker_recorded_event_attributes.marker_name = VERSION_MARKER_NAME
    event.marker_recorded_event_attributes.header = Header()
    event.marker_recorded_event_attributes.header.fields[MUTABLE_MARKER_HEADER_KEY] = bytes(marker_header_json, "utf-8")
    event.marker_recorded_event_attributes.details = b'4'
    return event
Ejemplo n.º 5
0
 def test_activity_task_timed_out(self):
     event = HistoryEvent(event_type=EventType.ActivityTaskTimedOut)
     event.event_id = 25
     attr = ActivityTaskTimedOutEventAttributes()
     attr.scheduled_event_id = 20
     attr.details = bytes("details", "utf-8")
     attr.timeout_type = TimeoutType.HEARTBEAT
     event.activity_task_timed_out_event_attributes = attr
     self.context.handle_activity_task_timed_out(event)
     self.assertTrue(self.future.done())
     exception = self.future.exception()
     self.assertIsInstance(exception, ActivityTaskTimeoutException)
     self.assertEqual(event.event_id, exception.event_id)
     self.assertEqual(attr.timeout_type, exception.timeout_type)
     self.assertEqual(attr.details, exception.details)
     self.assertEqual(0, len(self.context.scheduled_activities))