Skip to content

Commit 98845c6

Browse files
committed
Test: give time for handler wf events and change assertions
1 parent 8461429 commit 98845c6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/nexus/test_workflow_caller_cancellation_types.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ async def run(self, input: Input) -> CancellationResult:
8080
await op_handle
8181
except exceptions.NexusOperationError:
8282
caller_unblock_time = workflow.now()
83+
# Give time for handler wf cancellation event to be written if a request was sent
84+
await asyncio.sleep(0.5)
8385
assert op_handle.operation_token
8486
return CancellationResult(
8587
operation_token=op_handle.operation_token,
@@ -96,7 +98,6 @@ async def check_behavior_for_abandon(
9698
"""
9799
Check that a cancellation request is not sent.
98100
"""
99-
await asyncio.sleep(0.5)
100101
handler_status = (await handler_wf.describe()).status
101102
assert handler_status == WorkflowExecutionStatus.RUNNING
102103
await _assert_event_subsequence(
@@ -120,19 +121,18 @@ async def check_behavior_for_try_cancel(
120121
canceled.
121122
"""
122123
handler_status = (await handler_wf.describe()).status
123-
assert handler_status == WorkflowExecutionStatus.RUNNING
124+
assert handler_status == WorkflowExecutionStatus.CANCELED
124125
await _assert_event_subsequence(
125126
[
126127
(caller_wf, EventType.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED),
127128
(caller_wf, EventType.EVENT_TYPE_NEXUS_OPERATION_CANCEL_REQUESTED),
129+
(
130+
handler_wf,
131+
EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CANCEL_REQUESTED,
132+
),
128133
(caller_wf, EventType.EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED),
129134
]
130135
)
131-
# This event would be seen if the caller workflow stayed alive longer.
132-
assert not await _has_event(
133-
handler_wf,
134-
EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CANCEL_REQUESTED,
135-
)
136136

137137

138138
async def check_behavior_for_wait_cancellation_completed(

0 commit comments

Comments
 (0)