|
5 | 5 | from dataclasses import dataclass
|
6 | 6 | from datetime import timedelta
|
7 | 7 | from enum import Enum
|
8 |
| -from typing import Any, Iterator |
| 8 | +from typing import Any, Iterator, Mapping, Optional |
9 | 9 | from unittest.mock import patch
|
10 | 10 |
|
11 | 11 | import pytest
|
12 | 12 |
|
| 13 | +import temporalio.api.common.v1 |
| 14 | +import temporalio.api.workflowservice.v1 |
13 | 15 | from temporalio import activity, workflow
|
14 | 16 | from temporalio.client import (
|
15 | 17 | Client,
|
|
25 | 27 | WorkflowIDConflictPolicy,
|
26 | 28 | )
|
27 | 29 | from temporalio.exceptions import ApplicationError, WorkflowAlreadyStartedError
|
| 30 | +from temporalio.service import RPCError, RPCStatusCode, ServiceCall |
28 | 31 | from temporalio.testing import WorkflowEnvironment
|
29 | 32 | from tests.helpers import (
|
30 | 33 | new_worker,
|
@@ -805,3 +808,49 @@ async def test_update_with_start_two_param(client: Client):
|
805 | 808 | assert await wf_handle.result() == WorkflowResult(
|
806 | 809 | result="workflow-arg1-workflow-arg2"
|
807 | 810 | )
|
| 811 | + |
| 812 | + |
| 813 | +# Verify correcting issue #791 |
| 814 | +async def test_start_update_with_start_empty_details(client: Client): |
| 815 | + class execute_multi_operation( |
| 816 | + ServiceCall[ |
| 817 | + temporalio.api.workflowservice.v1.ExecuteMultiOperationRequest, |
| 818 | + temporalio.api.workflowservice.v1.ExecuteMultiOperationResponse, |
| 819 | + ] |
| 820 | + ): |
| 821 | + empty_details_err = RPCError("empty details", RPCStatusCode.INTERNAL, b"") |
| 822 | + # Set grpc_status with empty details |
| 823 | + empty_details_err._grpc_status = temporalio.api.common.v1.GrpcStatus(details=[]) |
| 824 | + |
| 825 | + def __init__(self) -> None: |
| 826 | + pass |
| 827 | + |
| 828 | + async def __call__( |
| 829 | + self, |
| 830 | + req: temporalio.api.workflowservice.v1.ExecuteMultiOperationRequest, |
| 831 | + *, |
| 832 | + retry: bool = False, |
| 833 | + metadata: Mapping[str, str] = {}, |
| 834 | + timeout: Optional[timedelta] = None, |
| 835 | + ) -> temporalio.api.workflowservice.v1.ExecuteMultiOperationResponse: |
| 836 | + raise self.empty_details_err |
| 837 | + |
| 838 | + with patch.object( |
| 839 | + client.workflow_service, "execute_multi_operation", execute_multi_operation() |
| 840 | + ): |
| 841 | + with pytest.raises(RPCError) as err: |
| 842 | + await client.start_update_with_start_workflow( |
| 843 | + UpdateWithStartInterceptorWorkflow.my_update, |
| 844 | + "original-update-arg", |
| 845 | + start_workflow_operation=WithStartWorkflowOperation( |
| 846 | + UpdateWithStartInterceptorWorkflow.run, |
| 847 | + "wf-arg", |
| 848 | + id=f"wf-{uuid.uuid4()}", |
| 849 | + task_queue="tq", |
| 850 | + id_conflict_policy=WorkflowIDConflictPolicy.FAIL, |
| 851 | + ), |
| 852 | + wait_for_stage=WorkflowUpdateStage.ACCEPTED, |
| 853 | + ) |
| 854 | + assert err.value.status == RPCStatusCode.INTERNAL |
| 855 | + assert err.value.message == "empty details" |
| 856 | + assert len(err.value.grpc_status.details) == 0 |
0 commit comments