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
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
def test_handle_marker_recorded_version(clock_decision_context): event = HistoryEvent(event_type=EventType.MarkerRecorded) event.marker_recorded_event_attributes = MarkerRecordedEventAttributes() event.marker_recorded_event_attributes.details = "Blahh" 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( json.dumps({ "id": "the-id", "eventId": 20, "accessCount": 0 }), "utf-8") clock_decision_context.handle_marker_recorded(event) assert "the-id" in clock_decision_context.version_handler.mutable_marker_results assert clock_decision_context.version_handler.mutable_marker_results[ "the-id"].data == "Blahh"
def test_process_decision_events_markers_first(self): self.decider.event_loop = Mock() marker_event = HistoryEvent(event_type=EventType.MarkerRecorded) marker_event.marker_recorded_event_attributes = MarkerRecordedEventAttributes( ) marker_event.marker_recorded_event_attributes.marker_name = VERSION_MARKER_NAME events = [ HistoryEvent(event_type=EventType.WorkflowExecutionStarted, workflow_execution_started_event_attributes= WorkflowExecutionStartedEventAttributes()), HistoryEvent(event_type=EventType.DecisionTaskScheduled), marker_event ] decision_events = DecisionEvents([], events, replay=True, replay_current_time_milliseconds=0, next_decision_event_id=5) self.decider.process_event = Mock() self.decider.process_decision_events(decision_events) self.decider.process_event.assert_called() assert len(self.decider.process_event.call_args_list) == 4 args, kwargs = self.decider.process_event.call_args_list[0] assert id(args[0]) == id(marker_event)