|
14 | 14 | Client, |
15 | 15 | Interceptor, |
16 | 16 | OutboundInterceptor, |
17 | | - RPCError, |
18 | 17 | StartWorkflowUpdateWithStartInput, |
19 | 18 | WithStartWorkflowOperation, |
20 | 19 | WorkflowUpdateFailedError, |
|
24 | 23 | from temporalio.common import ( |
25 | 24 | WorkflowIDConflictPolicy, |
26 | 25 | ) |
27 | | -from temporalio.exceptions import ApplicationError |
28 | | -from temporalio.service import RPCStatusCode |
| 26 | +from temporalio.exceptions import ApplicationError, WorkflowAlreadyStartedError |
29 | 27 | from tests.helpers import ( |
30 | 28 | new_worker, |
31 | 29 | ) |
@@ -230,15 +228,14 @@ async def _do_execute_update_test( |
230 | 228 | await start_op_2.workflow_handle() |
231 | 229 | ).first_execution_run_id is not None |
232 | 230 | else: |
233 | | - with pytest.raises(RPCError) as e: |
234 | | - await client.execute_update_with_start_workflow( |
| 231 | + for aw in [ |
| 232 | + client.execute_update_with_start_workflow( |
235 | 233 | update_handler, "21", start_workflow_operation=start_op_2 |
236 | | - ) |
237 | | - |
238 | | - assert e.value.grpc_status.code == RPCStatusCode.ALREADY_EXISTS |
239 | | - with pytest.raises(RPCError) as e2: |
240 | | - await start_op_2.workflow_handle() |
241 | | - assert e2.value.grpc_status.code == RPCStatusCode.ALREADY_EXISTS |
| 234 | + ), |
| 235 | + start_op_2.workflow_handle(), |
| 236 | + ]: |
| 237 | + with pytest.raises(WorkflowAlreadyStartedError): |
| 238 | + await aw |
242 | 239 |
|
243 | 240 | assert ( |
244 | 241 | await start_op_1.workflow_handle() |
@@ -337,18 +334,18 @@ def make_start_op(workflow_id: str): |
337 | 334 | # Second UWS start fails because the workflow already exists |
338 | 335 | # first execution run ID is not set on the second UWS handle |
339 | 336 | start_op_2 = make_start_op("wid-1") |
340 | | - with pytest.raises(RPCError) as exc_info: |
341 | | - await client.start_update_with_start_workflow( |
| 337 | + |
| 338 | + for aw in [ |
| 339 | + client.start_update_with_start_workflow( |
342 | 340 | WorkflowForUpdateWithStartTest.my_non_blocking_update, |
343 | 341 | "2", |
344 | 342 | wait_for_stage=WorkflowUpdateStage.COMPLETED, |
345 | 343 | start_workflow_operation=start_op_2, |
346 | | - ) |
347 | | - assert exc_info.value.status == RPCStatusCode.ALREADY_EXISTS |
348 | | - |
349 | | - with pytest.raises(RPCError) as e2: |
350 | | - await start_op_2.workflow_handle() |
351 | | - assert e2.value.grpc_status.code == RPCStatusCode.ALREADY_EXISTS |
| 344 | + ), |
| 345 | + start_op_2.workflow_handle(), |
| 346 | + ]: |
| 347 | + with pytest.raises(WorkflowAlreadyStartedError): |
| 348 | + await aw |
352 | 349 |
|
353 | 350 | # Third UWS start succeeds, but the update fails after acceptance |
354 | 351 | start_op_3 = make_start_op("wid-2") |
@@ -421,18 +418,18 @@ def make_start_op(workflow_id: str): |
421 | 418 | ) |
422 | 419 |
|
423 | 420 | start_op_2 = make_start_op(wid) |
424 | | - with pytest.raises(RPCError) as exc_info: |
425 | | - await client.start_update_with_start_workflow( |
| 421 | + |
| 422 | + for aw in [ |
| 423 | + client.start_update_with_start_workflow( |
426 | 424 | WorkflowForUpdateWithStartTest.my_non_blocking_update, |
427 | 425 | "2", |
428 | 426 | wait_for_stage=WorkflowUpdateStage.COMPLETED, |
429 | 427 | start_workflow_operation=start_op_2, |
430 | | - ) |
431 | | - assert exc_info.value.grpc_status.code == RPCStatusCode.ALREADY_EXISTS |
432 | | - |
433 | | - with pytest.raises(RPCError) as exc_info2: |
434 | | - await start_op_2.workflow_handle() |
435 | | - assert exc_info2.value.grpc_status.code == RPCStatusCode.ALREADY_EXISTS |
| 428 | + ), |
| 429 | + start_op_2.workflow_handle(), |
| 430 | + ]: |
| 431 | + with pytest.raises(WorkflowAlreadyStartedError): |
| 432 | + await aw |
436 | 433 |
|
437 | 434 |
|
438 | 435 | async def test_workflow_update_poll_loop(client: Client): |
|
0 commit comments