Skip to content

Commit c338014

Browse files
committed
revert unwanted changes
Signed-off-by: Shijie Sheng <[email protected]>
1 parent c8d58bc commit c338014

File tree

2 files changed

+60
-61
lines changed

2 files changed

+60
-61
lines changed

tests/cadence/_internal/workflow/test_decision_events_iterator.py

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
Tests for Decision Events Iterator.
44
"""
55

6+
from typing import List
67
import pytest
78

89

910
from cadence._internal.workflow.decision_events_iterator import (
1011
DecisionEventsIterator,
1112
)
12-
from tests.cadence._internal.workflow.utils import create_mock_history_event
13+
from cadence.api.v1.history_pb2 import HistoryEvent
1314

1415

1516
class TestDecisionEventsIterator:
@@ -104,3 +105,61 @@ def test_successful_cases(self, name, event_types, expected):
104105
assert batch.replay == expect["replay"]
105106
assert batch.replay_current_time_milliseconds == expect["replay_time"]
106107
assert batch.next_decision_event_id == expect["next_decision_event_id"]
108+
109+
110+
def create_mock_history_event(event_types: List[str]) -> List[HistoryEvent]:
111+
events = []
112+
for i, event_type in enumerate(event_types):
113+
event = HistoryEvent()
114+
event.event_id = i + 1
115+
event.event_time.FromMilliseconds((i + 1) * 1000)
116+
117+
# Set the appropriate attribute based on event type
118+
if event_type == "decision_task_started":
119+
event.decision_task_started_event_attributes.SetInParent()
120+
elif event_type == "decision_task_completed":
121+
event.decision_task_completed_event_attributes.SetInParent()
122+
elif event_type == "decision_task_failed":
123+
event.decision_task_failed_event_attributes.SetInParent()
124+
elif event_type == "decision_task_timed_out":
125+
event.decision_task_timed_out_event_attributes.SetInParent()
126+
elif event_type == "marker_recorded":
127+
event.marker_recorded_event_attributes.SetInParent()
128+
elif event_type == "activity_scheduled":
129+
event.activity_task_scheduled_event_attributes.SetInParent()
130+
elif event_type == "activity_started":
131+
event.activity_task_started_event_attributes.SetInParent()
132+
elif event_type == "activity_completed":
133+
event.activity_task_completed_event_attributes.SetInParent()
134+
elif event_type == "activity_failed":
135+
event.activity_task_failed_event_attributes.SetInParent()
136+
elif event_type == "activity_timed_out":
137+
event.activity_task_timed_out_event_attributes.SetInParent()
138+
elif event_type == "activity_cancel_requested":
139+
event.activity_task_cancel_requested_event_attributes.SetInParent()
140+
elif event_type == "request_cancel_activity_task_failed":
141+
event.request_cancel_activity_task_failed_event_attributes.SetInParent()
142+
elif event_type == "activity_canceled":
143+
event.activity_task_canceled_event_attributes.SetInParent()
144+
elif event_type == "timer_started":
145+
event.timer_started_event_attributes.SetInParent()
146+
elif event_type == "timer_fired":
147+
event.timer_fired_event_attributes.SetInParent()
148+
elif event_type == "timer_canceled":
149+
event.timer_canceled_event_attributes.SetInParent()
150+
elif event_type == "cancel_timer_failed":
151+
event.cancel_timer_failed_event_attributes.SetInParent()
152+
elif event_type == "request_cancel_external_workflow_execution_initiated":
153+
event.request_cancel_external_workflow_execution_initiated_event_attributes.SetInParent()
154+
elif event_type == "request_cancel_external_workflow_execution_failed":
155+
event.request_cancel_external_workflow_execution_failed_event_attributes.SetInParent()
156+
elif event_type == "external_workflow_execution_cancel_requested":
157+
event.external_workflow_execution_cancel_requested_event_attributes.SetInParent()
158+
elif event_type == "workflow_execution_started":
159+
event.workflow_execution_started_event_attributes.SetInParent()
160+
elif event_type == "workflow_execution_completed":
161+
event.workflow_execution_completed_event_attributes.SetInParent()
162+
163+
events.append(event)
164+
165+
return events

tests/cadence/_internal/workflow/utils.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)